Skip to content

Instantly share code, notes, and snippets.

@flying-sheep
Created March 13, 2015 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flying-sheep/0cf393e9d88eb4351aec to your computer and use it in GitHub Desktop.
Save flying-sheep/0cf393e9d88eb4351aec to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Reddit stylesheet editor
// @namespace flying-sheep
// @description CodeMirror-based stylesheet editor for reddit mods
// @include http://www.reddit.com/r/*/about/stylesheet/
// @version 1
// @require https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/codemirror.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/addon/hint/show-hint.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/mode/css/css.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/addon/hint/css-hint.js
// @resource mainCSS https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/codemirror.min.js
// @resource themCSS https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/theme/ambiance.min.css
// @resource hintCSS https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/addon/hint/show-hint.min.css
// @grant GM_addStyle
// @grant GM_getResourceText
// ==/UserScript==
// more stuff: https://cdnjs.com/libraries/codemirror
// docs: http://codemirror.net/doc/manual.html
try {
GM_addStyle(GM_getResourceText('mainCSS'))
GM_addStyle(GM_getResourceText('themCSS'))
GM_addStyle(GM_getResourceText('hintCSS'))
var textAreaID = 'stylesheet_contents'
var textArea = document.getElementById(textAreaID)
var myCodeMirror = CodeMirror.fromTextArea(textArea, {
lineNumbers: true,
gutter: true,
mode: 'css',
theme: 'ambiance',
indentWithTabs: true,
})
} catch (e) {
console.error(e)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment