Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==UserScript==
// @name User Block on Parrot USA Forum
// @namespace com.silentexception
// @version 0.2
// @description Block Users (Posts and Threads) on Parrot USA Forum
// @author SilentException
// @include http://forum.parrot.com/usa/*
// @match http://forum.parrot.com/usa/*
// @grant none
// ==/UserScript==
var ignore = ["user1", "user2"]; // can add more, can use regular expression
var posts = document.getElementsByClassName("postbody");
for(var i = 0; i < posts.length; i++) {
for (var j = 0; j < ignore.length; j++) {
var ignore_patt = new RegExp(ignore[j]);
if (ignore_patt.test(posts[i].childNodes[1].childNodes[1].childNodes[1].childNodes[0].innerHTML)) {
var postbody = posts[i];
var post = postbody.parentNode;
var postParent = post.parentNode;
var postCopy = post.cloneNode(true);
post.setAttribute("style", "display: none");
for (var k = postCopy.childNodes[1].childNodes.length - 1; k >= 0; k--)
postCopy.childNodes[1].removeChild(postCopy.childNodes[1].childNodes[k]);
for (var k = postCopy.childNodes[3].childNodes.length - 1; k >= 0; k--)
postCopy.childNodes[3].removeChild(postCopy.childNodes[3].childNodes[k]);
var newPostLink = document.createElement("a");
newPostLink.setAttribute("onclick", "this.parentNode.parentNode.nextSibling.style.display = 'block'; this.parentNode.parentNode.style.display = 'none'; return false;");
newPostLink.setAttribute("href", "#");
newPostLink.innerHTML = "<p><b>Blocked, click to show</b><p>";
postCopy.childNodes[3].appendChild(newPostLink);
postParent.insertBefore(postCopy, post);
console.log(newPostLink.parentNode.parentNode.nextSibling.innerHTML);
i++;
}
}
}
var threads = document.getElementsByClassName("main-item");
for(var i = 0; i < threads.length; i++) {
for (var j = 0; j < ignore.length; j++) {
var ignore_patt = new RegExp(ignore[j]);
if (ignore_patt.test(threads[i].childNodes[3].childNodes[3].childNodes[0].childNodes[1].innerHTML)) {
var thread = threads[i];
var threadParent = threads[i].parentNode;
var threadCopy = thread.cloneNode(true);
thread.setAttribute("style", "display: none");
for (var k = threadCopy.childNodes[3].childNodes.length - 1; k >= 0; k--)
threadCopy.childNodes[3].removeChild(threadCopy.childNodes[3].childNodes[k]);
for (var k = threadCopy.childNodes[5].childNodes.length - 1; k >= 0; k--)
threadCopy.childNodes[5].removeChild(threadCopy.childNodes[5].childNodes[k]);
var newThreadLinkH = document.createElement("h3")
newThreadLinkH.setAttribute("class", "hn");
var newThreadLinkSpan = document.createElement("span");
newThreadLinkSpan.setAttribute("class", "item-num");
newThreadLinkSpan.innerHTML = "99";
var newThreadLink = document.createElement("a");
newThreadLink.setAttribute("onclick", "this.parentNode.parentNode.parentNode.nextSibling.style.display = 'block'; this.parentNode.parentNode.parentNode.style.display = 'none'; return false;");
newThreadLink.setAttribute("href", "#");
newThreadLink.innerHTML = "<b>Blocked, click to show</b>";
newThreadLinkH.appendChild(newThreadLinkSpan);
newThreadLinkH.appendChild(newThreadLink)
threadCopy.childNodes[3].appendChild(newThreadLinkH);
threadParent.insertBefore(threadCopy, thread);
i++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.