Last active
February 6, 2018 15:16
-
-
Save epicTCK/3de6fd796d7d3d8f172f6158a9a93be4 to your computer and use it in GitHub Desktop.
letsrun userscript wip
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 Let's Run | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Make Let's Run more usable | |
// @author Caleb Gentry | |
// @match http://www.letsrun.com/forum/* | |
// @grant GM_addStyle | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
//change these to use as settings | |
var blacklist = [""]; // add names to prevent certain user's posts from showing up | |
var maxLength = 700; // The length in pixels a post must be in order to collapse it. I hate scrolling through spam/long posts while reading, so this collapses them. | |
// makes nested quotes a whole lot more compact and easier to read | |
GM_addStyle('blockquote{border-right:0 !important; border-bottom:0 !important; border-top:0 !important; margin:20px !important; padding:2px !important} .notice{color: red;}'); | |
//The idea was to collapse long posts. It needs some work. commenting it out for now. | |
for(let x of document.getElementsByClassName("post_text")){ | |
if(x.clientHeight > maxLength){ | |
x.style.overflow = "hidden"; | |
x.style.height = "300px"; | |
let a = "<i class = \"notice\"> Note: this post is collapsed. Click to expand.</i>"; | |
let b = "<i class = \"notice\"> Note: this post is expanded. Click to collapse.</i>"; | |
x.innerHTML = a + x.innerHTML; | |
x.addEventListener("click", function(){ | |
for(let u of this.getElementsByClassName("notice")){u.parentNode.removeChild(u);} | |
this.style.height = this.style.height == "auto"?"300px":"auto"; | |
this.innerHTML = this.style.height == "auto"?b + this.innerHTML:a + this.innerHTML; | |
}); | |
} | |
} | |
//to block posters using a blacklist | |
for(let x of document.getElementsByClassName("author")){ | |
if(x.getElementsByTagName("strong").length > 0){ | |
if(blacklist.includes(x.getElementsByTagName("strong")[0].innerHTML)){ | |
let parent = x.parentNode; | |
parent.parentNode.removeChild(parent); | |
} | |
} | |
else{ | |
if(blacklist.includes(x.innerHTML)){ | |
let parent = x.parentNode; | |
parent.parentNode.removeChild(parent); | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment