Skip to content

Instantly share code, notes, and snippets.

@radthemad4
Last active April 14, 2023 17:04
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 radthemad4/feac95333463bcaf5ca28e7ae7ea7f84 to your computer and use it in GitHub Desktop.
Save radthemad4/feac95333463bcaf5ca28e7ae7ea7f84 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Den Spoilers
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Spoiler functionality
// @author You
// @match http://www.tgdmb.com/phpBB3/*
// @match http://tgdmb.com/phpBB3/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tgdmb.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
for(let content of document.getElementsByClassName("content")) {
content.innerHTML = content.innerHTML.replaceAll(/\[spoiler\](.*?)\[\/spoiler\]/gs,
"\<style\>"+
" summary \{"+
" user\-select\: none;"+
" outline\: 0 \!important;"+
" \}"+
""+
" summary \.bbctitle \{"+
" font\-weight\: bold;"+
" padding\-left\: 5px;"+
" cursor\: pointer;"+
" \}"+
""+
" summary\:\:\-webkit\-details\-marker \{"+
" display\: none"+
" \}"+
""+
" summary\:\:before \{"+
" float\: left;"+
" padding\-left\: 1px;"+
" font\-family\: \"FontAwesome\";"+
" content\: \"\\f055\";"+
" cursor\: pointer;"+
" \}"+
""+
" details\[open\] summary\:\:before \{"+
" content\: \"\\f056\";"+
" \}"+
""+
" details\.bbcspoiler\[open\] summary\:\:after \{"+
" content\: attr\(title\-open\);"+
" font\-weight\: bold;"+
" cursor\: pointer;"+
" \}"+
""+
" details\.bbcspoiler\:not\(\[open\]\) summary\:\:after \{"+
" content\: attr\(title\-close\);"+
" font\-weight\: bold;"+
" cursor\: pointer;"+
" \}"+
""+
" details \.bbccontent \{"+
" margin\-top\: 3px;"+
" margin\-bottom\: 15px;"+
" margin\-left\: 15px;"+
" \}"+
"\</style\>"+
"<details class='bbcspoiler'>"+
"<summary title-open='Collapse view' title-close='Display'><span class='bbctitle'></span></summary>"+
"<div class='bbccontent'>$1</div>"+
"</details>"
);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment