Last active
February 15, 2020 11:27
-
-
Save kasimi/c33fdf4af9a4de324d446c0a50996366 to your computer and use it in GitHub Desktop.
Greasemonkey script for phpBB boards that hides posts of certain users
This file contains hidden or 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 phpBB foes | |
// @namespace https://kasimi.net | |
// @description Hides foes' posts | |
// @include https://www.phpbb.com/community/viewtopic.php* | |
// @version 2 | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
let usernames = [ | |
'Foe username', | |
'Another foe username', | |
]; | |
let censor = username => `<center>Hidden post by <strong>${username}</strong></center>`; | |
let removeClass = (elem, cls) => { elem.className = elem.className.replace(new RegExp('(?:^|\\s)'+ cls + '(?:\\s|$)'), ' '); }; | |
for (let post of document.querySelectorAll('.post, #posts > div')) { | |
let usernameLink = post.querySelector('a.username, a.username-coloured'); | |
if (usernameLink) { | |
let username = usernameLink.innerHTML; | |
if (usernames.includes(username)) { | |
removeClass(post, 'online'); | |
post.className += ' panel'; | |
post.innerHTML = censor(username); | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
“Arrow function should not return assignment”, warns Tampermonkey about line 18.