Greasy Fork

Greasy Fork is available in English.

Oracle iAcademy Suck-Less

Basic Syntax Highlighting and Auto-Completion. Enter key intelligently Auto-completes or Auto-Runs the query. Table names completion NYI.

当前为 2016-12-03 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Oracle iAcademy Suck-Less
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Basic Syntax Highlighting and Auto-Completion. Enter key intelligently Auto-completes or Auto-Runs the query. Table names completion NYI.
// @author       You
// @match        https://iacademy.oracle.com/*
// @require      https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.21.0/codemirror.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.21.0/addon/hint/show-hint.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.21.0/addon/hint/sql-hint.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.21.0/mode/sql/sql.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.21.0/addon/selection/active-line.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.21.0/addon/edit/matchbrackets.js
// ==/UserScript==
// @require      https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.21.0/codemirror.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.21.0/mode/sql/sql.js
function importScript(src) {
    var script = document.createElement('script');
    script.type = "text/javascript";
    script.src = src;
    document.body.appendChild(script);
    return script;
}
function importCSS(src) {
    var script = document.createElement('link');
    script.type = "text/css";
    script.rel='stylesheet';
    script.href = src;
    document.head.appendChild(script);
    return script;
}
importCSS("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.21.0/codemirror.css");
importCSS("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.21.0/addon/hint/show-hint.css");
/*importScript("https://esironal.github.io/cmtouch/lib/codemirror.js");
importScript("https://esironal.github.io/cmtouch/addon/hint/show-hint.js");
importScript("https://esironal.github.io/cmtouch/addon/hint/xml-hint.js");
importScript("https://esironal.github.io/cmtouch/addon/hint/html-hint.js");
importScript("https://esironal.github.io/cmtouch/mode/xml/xml.js");
importScript("https://esironal.github.io/cmtouch/mode/javascript/javascript.js");
importScript("https://esironal.github.io/cmtouch/mode/css/css.js");
importScript("https://esironal.github.io/cmtouch/mode/htmlmixed/htmlmixed.js");
importScript("https://esironal.github.io/cmtouch/mode/sql/sql.js");
importScript("https://esironal.github.io/cmtouch/addon/selection/active-line.js");
importScript("https://esironal.github.io/cmtouch/addon/edit/matchbrackets.js");*/
importCSS("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.21.0/theme/neonsyntax.css");
//importScript();
/* highlight js
importScript('//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/highlight.min.js');
importCSS('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/default.min.css');
hljs.configure({useBR: true});
window.hljs=hljs;
SQL_Box.className += " sql code";
hljs.initHighlightingOnLoad();
hljs.highlightBlock(SQL_Box);

*/
//importScript('https://codemirror.net/lib/codemirror.js');
//importCSS('https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.21.0/codemirror.css');
// Wait a second or lineNumber will develop a overlaping problem
setTimeout(function() {

    
var ExcludedIntelliSenseTriggerKeys =
{
    "8": "backspace",
    "9": "tab",
    "13": "enter",
    "16": "shift",
    "17": "ctrl",
    "18": "alt",
    "19": "pause",
    "20": "capslock",
    "27": "escape",
    "33": "pageup",
    "34": "pagedown",
    "35": "end",
    "36": "home",
    "37": "left",
    "38": "up",
    "39": "right",
    "40": "down",
    "45": "insert",
    "46": "delete",
    "91": "left window key",
    "92": "right window key",
    "93": "select",
    "107": "add",
    "109": "subtract",
    "110": "decimal point",
    "111": "divide",
    "112": "f1",
    "113": "f2",
    "114": "f3",
    "115": "f4",
    "116": "f5",
    "117": "f6",
    "118": "f7",
    "119": "f8",
    "120": "f9",
    "121": "f10",
    "122": "f11",
    "123": "f12",
    "144": "numlock",
    "145": "scrolllock",
    "186": "semicolon",
    "187": "equalsign",
    "188": "comma",
    "189": "dash",
    "190": "period",
    "191": "slash",
    "192": "graveaccent",
    "220": "backslash",
    "222": "quote"
};


var RunBtn = document.getElementsByClassName('aButton hotButton')[0];
var RunSQL_Cmd;
if (RunBtn.textContent == 'Run') {
    RunSQL_Cmd = RunBtn.onclick;
}
    
var SQL_Box = document.getElementById('P1003_SQL_COMMAND1');
    CodeMirror.commands.autocomplete = function(cm) {
			CodeMirror.showHint(cm, CodeMirror.hint.sql);
		};
    var SQL_Mirror = CodeMirror.fromTextArea(SQL_Box, {
    mode: "text/x-sql",
    //theme: "neonsyntax",
    lineWrapping: true,
    lineNumbers: true,
    styleActiveLine: true,
    extraKeys: {
					"Ctrl-Space": "autocomplete"
				},
    matchBrackets: true,
  });
    SQL_Mirror.on("keyup", function(editor, event) {
        var __Cursor = editor.getDoc().getCursor();
        var __Token = editor.getTokenAt(__Cursor);

        if (!editor.state.completionActive &&
            !ExcludedIntelliSenseTriggerKeys[(event.keyCode || event.which).toString()] &&
            (__Token.type == "tag" || __Token.string == " " || __Token.string == "<" || __Token.string == "/" ))
        {
            CodeMirror.commands.autocomplete(editor, null, { completeSingle: false });
        } else if (event.keyCode == 13 && event.shiftKey === false) {
            RunSQL_Cmd();
            // TODO eat the enter keypress
        }
    });
    SQL_Mirror.setSize(SQL_Box.style.width, '100%');
    SQL_Mirror.on("change", function(cm, change) { cm.save(); });



    
}, 1000);