Skip to content

Instantly share code, notes, and snippets.

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 brillenfux/ef8b28cfa520fac7256676eaee53e55b to your computer and use it in GitHub Desktop.
Save brillenfux/ef8b28cfa520fac7256676eaee53e55b to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Reddit spoilers without custom CSS
// @description Show correct spoiler formatting for Reddit even without custom CSS
// @author /u/brillenfukx
// @match *://www.reddit.com/*/comments/*
// @run-at document-start
// @version 0.1
// ==/UserScript==
(function() {var css = [
"a[href='#s'] {",
" display: inline-block;",
" //background: lightgrey !important;",
" color: #222222 !important;",
" cursor: text;",
"}",
"a[href='#s']::after {",
" content: attr(title);",
" background: #222222 !important;",
" color: #222222 !important;",
" visibility: visible;",
" border-radius: 3px;",
" padding: 0 3px;",
" margin-left: 5px;",
"}",
"a[href='#s']:hover::after, a[href='#s']:active::after {",
" background: white !important;",
" //background: lightgrey !important;",
" //color: white !important;",
"}"
].join("\n");
if (typeof GM_addStyle != "undefined") {
GM_addStyle(css);
} else if (typeof PRO_addStyle != "undefined") {
PRO_addStyle(css);
} else if (typeof addStyle != "undefined") {
addStyle(css);
} else {
var node = document.createElement("style");
node.type = "text/css";
node.appendChild(document.createTextNode(css));
var heads = document.getElementsByTagName("head");
if (heads.length > 0) {
heads[0].appendChild(node);
} else {
// no head yet, stick it whereever
document.documentElement.appendChild(node);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment