Created
June 20, 2016 21:02
-
-
Save digitalfiz/ca7bf3b05d17b479388029b1bbb2827f to your computer and use it in GitHub Desktop.
Aced out GameServers.com Config editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Aced out GameServers.com Config editor | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description This script adds the ace editor to the config editor on gameservers.com | |
// @author digitalfiz <https://twitter.com/digitalfiz> | |
// @match https://my.gameservers.com/home/subscription_info.php?view=server_configuration&* | |
// @grant none | |
// ==/UserScript== | |
function buildEditor(syntax) { | |
var textarea = $('textarea[name="advanced_editor_content"]'); | |
// create div with the editors contents | |
$(textarea).before('<div id="editor">' + $(textarea).text() + '</div>'); | |
// make it purdy | |
$("#editor").css('width', '100%'); | |
$("#editor").css('height', '400px'); | |
$("#editor").css('margin-top', '10px'); | |
// Setup editor on new div | |
var editor = ace.edit('editor'); | |
editor.setTheme('ace/theme/tomorrow_night'); | |
// Add syntax highlighting | |
editor.getSession().setMode('ace/mode/' + syntax); | |
// Loop changes back to the textarea | |
editor.getSession().on('change', function () { | |
textarea.val(editor.getSession().getValue()); | |
}); | |
// Now lets hide the textarea | |
$(textarea).hide(); | |
} | |
(function () { | |
'use strict'; | |
var sel = $('select[name="GMCONFIGID"] option:selected').text(); | |
var syntax = 'plain_text'; | |
if (sel.indexOf('.ini') >= 0) { | |
syntax = 'ini'; | |
} else if (sel.indexOf('Server Command Line') >= 0) { | |
syntax = 'sh'; | |
} | |
// Load up ace! | |
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.3/ace.js').done(function( script, textStatus ) { | |
// remote script has loaded | |
console.log('loaded ace'); | |
buildEditor(syntax); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment