Last active
December 22, 2019 16:14
-
-
Save ReactiioN1337/e012dd6108e48e96b123bc936c1a5518 to your computer and use it in GitHub Desktop.
Hides posts on unknowncheats.me that are below a certain reputation threshold or ignored.
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 Hide Noobs, make UC readable again! | |
// @namespace UnKnoWnCheaTs | |
// @match *://www.unknowncheats.me/* | |
// @grant none | |
// @version 0.2 | |
// @author ReactiioN, Robater | |
// @description Hides posts on unknowncheats.me that are below a certain reputation threshold or ignored. | |
// ==/UserScript== | |
window.onload = () => { | |
const minReputation = 0 | |
const ignoredUsers = [] | |
const userUrlPattern = /\/members\/(\d+).html/m | |
const hasMinRep = post => { | |
const selector = post.querySelector('[id^=repinfoRep_]') | |
return selector === null | |
? false // user has been banned | |
: parseInt(selector.innerText) >= minReputation | |
} | |
const isIgnored = post => { | |
if (ignoredUsers.length > 0) { | |
const selector = post.querySelector('[id^=postmenu_] .bigusername') | |
if (selector) { | |
const match = userUrlPattern.exec(selector.getAttribute('href')) | |
if (match) { | |
return ignoredUsers.includes(parseInt(match[1])) | |
} | |
} | |
} | |
return false | |
} | |
const posts = document.querySelectorAll('#posts .page') | |
if (posts !== null) { | |
for (const post of posts) { | |
if (!hasMinRep(post) || isIgnored(post)) { | |
post.remove() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment