Last active
June 14, 2017 02:39
-
-
Save Veedrac/8e19b6802d5c3f0d4d991d1f78a2a81c to your computer and use it in GitHub Desktop.
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 Sufficient Velocity User Filter | |
// @version 1.0 | |
// @description Restyle the page and allow selective ignore of specific threads | |
// @author Veedrac | |
// @match https://forums.sufficientvelocity.com/* | |
// @exclude https://forums.sufficientvelocity.com/watched/threads | |
// @run-at document-start | |
// @grant none | |
// ==/UserScript== | |
/* jshint esnext: true */ | |
(function() { | |
"use strict"; | |
var rules = ""; | |
var rule = (x, y) => rules += x + " { " + y + " !important; }\n"; | |
rule(".message .messageContent", "min-height: 0"); | |
rule(".message .messageInfo", "border: none"); | |
rule(".InlineModForm.section", "max-width: 920px"); | |
rule(".message .messageInfo", "box-shadow: none"); | |
rule(".mainContent", "border: none"); | |
rule(".messageUserInfo", "width: 114px"); | |
rule(".messageUserInfo", "padding-top: 10px"); | |
rule(".messageUserInfo", "padding-left: 9px"); | |
rule(".messageUserBlock", "border: none"); | |
rule(".messageUserBlock", "box-shadow: none"); | |
rule(".avatarHolder", "background: none"); | |
rule(".avatarHolder", "padding: 0"); | |
rule(".arrow", "display: none"); | |
rule(".messageInfo.primaryContent", "margin-left: 132px"); | |
rule(".Preview.blendedEditor", "margin-left: 0"); | |
rule(".Preview.blendedEditor", "border: none"); | |
rule(".Preview.blendedEditor", "box-shadow: none"); | |
rule(".tagList .tag .truncate", "max-width: none"); | |
var beauty = document.createElement('style'); | |
document.head.appendChild(beauty); | |
beauty.appendChild(document.createTextNode(rules)); | |
})(); | |
window.onload = function () { | |
"use strict"; | |
var style = document.createElement('style'); | |
document.head.appendChild(style); | |
style.sheet.insertRule(".sufficientvelocity-ignore-hidden .sufficientvelocity-ignore-button { display: none; }", 0); | |
style.sheet.insertRule(".discussionListItem:not(.sufficientvelocity-ignore-hidden) .sufficientvelocity-reveal-button { display: none; }", 0); | |
style.sheet.insertRule(".sufficientvelocity-ignore-hidden { display: none; }", 0); | |
var form = document.querySelector(".DiscussionListOptions"); | |
if (!form) { | |
return; | |
} | |
var threads = document.querySelectorAll(".discussionListItem"); | |
var reset_button = document.createElement("input"); | |
reset_button.setAttribute("type", "reset"); | |
reset_button.setAttribute("class", "button"); | |
reset_button.setAttribute("value", "Reset Ignore List"); | |
reset_button.onclick = function(event) { | |
localStorage["sufficientvelocity-ignore-base"] |= 0; | |
localStorage["sufficientvelocity-ignore-base"]++; | |
threads.forEach(function(thread) { | |
thread.classList.remove("sufficientvelocity-ignore-hidden"); | |
}); | |
return false; | |
}; | |
form.querySelector('.buttonGroup').appendChild(reset_button); | |
var reveal_button = document.createElement("input"); | |
reveal_button.setAttribute("type", "reset"); | |
reveal_button.setAttribute("class", "button"); | |
reveal_button.setAttribute("value", "Reveal Ignored"); | |
reveal_button.onclick = function(event) { | |
style.sheet.removeRule(0); | |
style.sheet.insertRule(".sufficientvelocity-ignore-hidden { opacity: 0.5; }", 0); | |
return false; | |
}; | |
form.querySelector('.buttonGroup').appendChild(reveal_button); | |
threads.forEach(function(thread) { | |
var ignore_button = document.createElement("input"); | |
ignore_button.setAttribute("type", "reset"); | |
ignore_button.setAttribute("class", "button sufficientvelocity-ignore-button"); | |
ignore_button.setAttribute("value", "ignore"); | |
ignore_button.onclick = function(event) { | |
localStorage["deworm-ignore-" + thread.id] = localStorage["sufficientvelocity-ignore-base"]; | |
thread.classList.add("sufficientvelocity-ignore-hidden"); | |
return false; | |
}; | |
thread.querySelector(".title").appendChild(ignore_button); | |
var reveal_button = document.createElement("input"); | |
reveal_button.setAttribute("type", "reset"); | |
reveal_button.setAttribute("class", "button sufficientvelocity-reveal-button"); | |
reveal_button.setAttribute("value", "reveal"); | |
reveal_button.onclick = function(event) { | |
delete localStorage["deworm-ignore-" + thread.id]; | |
thread.classList.remove("sufficientvelocity-ignore-hidden"); | |
return false; | |
}; | |
thread.querySelector(".title").appendChild(reveal_button); | |
if (localStorage["deworm-ignore-" + thread.id] == localStorage["sufficientvelocity-ignore-base"]) { | |
thread.classList.add("sufficientvelocity-ignore-hidden"); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment