NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name improveExecuteEditor
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author Flyink13
// @copyright 2018, flyink13 (https://openuserjs.org//users/flyink13)
// @license MIT
// @match https://vk.com/dev/execute*
// @grant none
// ==/UserScript==
/* global ce, ge, geByClass1, ace, extend, val, stopEvent, loadScript */
function improveExecuteEditor() {
if (!window.ge || !window.extend || !window.loadScript) return;
var codeInput = ge('dev_const_code');
var runButton = ge('dev_req_run_btn');
var resultInput = geByClass1('dev_req_result');
var aceWrapElem = document.body.appendChild(ce('div'));
var aceCorePath = '/js/ace/ace.js';
var aceToolPath = '/js/ace/ext-language_tools.js';
var panelStyles = {
width: '50%',
height: '100%',
top: 0,
left: 0,
position: 'fixed',
zIndex: 2000,
boxSizing: 'border-box'
};
function onAceLoad() {
var editor = ace.edit(aceWrapElem);
editor.getSession().setMode('ace/mode/javascript');
editor.setOption('enableSnippets', true);
editor.setOption('enableLiveAutocompletion', true);
extend(document.body.style, { overflow: 'hidden' });
extend(resultInput.style, panelStyles, { left: '50%', overflow: 'auto' });
extend(aceWrapElem.style, panelStyles);
val(editor, localStorage.last_dev_code || '// execute: Alt+E');
window.addEventListener("keydown", function onKeyDown(e) {
localStorage.last_dev_code = val(editor);
if (e.keyCode != 69 || !(e.altKey || e.metaKey)) return; // Alt+E
val(codeInput, val(editor));
runButton.click();
stopEvent(e);
});
}
loadScript(aceCorePath, {
onLoad: function() {
loadScript(aceToolPath, {
onLoad: onAceLoad
})
}
});
}
(function injectScript() {
var script = document.createElement('script');
script.appendChild(document.createTextNode('(' + improveExecuteEditor + ')();'));
(document.body || document.head || document.documentElement).appendChild(script);
})();