NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Golang Playground ACE editor
// @namespace http://teeed.eu/
// @version 0.3
// @description Make golang play editor usable.
// @author TadeuszMW tadeuszmw gmail.com
// @match https://play.golang.org/
// @match https://play.golang.org/p/*
// @grant GM_addStyle
// @license GPL-3.0
// @updateURL https://openuserjs.org/meta/Teeed/Golang_Playground_ACE_editor.meta.js
// @copyright 2018, Teeed (https://openuserjs.org/users/Teeed)
// ==/UserScript==
/*
0.3:
Also applies to code posted on playground.
0.2:
Ctrl + Enter executes script.
*/
(function() {
'use strict';
var scrpt = document.createElement('script');
scrpt.src = 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.3/ace.js'
scrpt.type = 'text/javascript';
scrpt.async = true;
scrpt.onload = function() {
var wrap = document.getElementById("wrap")
var linedTextarea = document.querySelector(".linedtextarea");
linedTextarea.style.display = 'none'
var codeArea = document.getElementById("code");
var currentCode = codeArea.value;
var editorDiv = document.createElement('div')
editorDiv.id = "newNiceEditorDiv"
editorDiv.style.width = '100%'
editorDiv.style.height = '100%'
wrap.appendChild(editorDiv);
var editor = ace.edit("newNiceEditorDiv");
editor.session.setValue(currentCode);
editor.session.on('change', function(){
codeArea.value = editor.session.getValue();
});
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/golang");
editorDiv.style.fontSize='16px';
function doSubmit() {
document.getElementById('run').click()
}
window.addEventListener("keypress", function(e) {
if(e.ctrlKey && e.key == 'Enter') {
doSubmit()
}
}, false);
}
document.head.appendChild(scrpt);
GM_addStyle ( `
#wrap {
padding: 0;
background: none;
}
#output {
background-color: black;
color: white;
}
`);
// Your code here...
})();