- Share this text:
DLP Ignore ++ v1.1 - posted by guest on 23rd December 2019 02:17:14 AM
// ==UserScript==
// @name DLP Ignore++
// @version 1.2
// @description Ignore DLP's most prolific wankers, "mods" or not
// @author BTT
// @match https://forums.darklordpotter.net/*
// @grant GM_setValue
// @grant GM_getValue
// @require https://d3js.org/d3.v4.min.js
// @require http://userscripts-mirror.org/scripts/source/107941.user.js
// ==/UserScript==
function isUserIgnored(username){
return GM_getValue("userIDs",[]).includes(username);
}
function isThreadIgnored(threadnum){
var blockedIDs = GM_getValue("threadIDs",[]);
return blockedIDs.includes(threadnum);
};
function ignore(){
'use strict';
var showIgnThreads = GM_getValue("showIgnoredThreads", false);
var showIgnUsers = GM_getValue("showIgnoredUsers", false);
var totalcount = d3.selectAll(".PreviewTooltip").size();
var origcount = totalcount;
d3.selectAll(".message").each(function(d){
var t = d3.select(this);
if (isUserIgnored(t.attr("data-author")) && !showIgnUsers){
t.style("display","none");
}
});
d3.selectAll(".messageSimple").each(function(d){
var t = d3.select(this);
if (isUserIgnored(t.attr("data-author")) && !showIgnUsers){
t.style("display","none");
}
});
d3.selectAll(".PreviewTooltip").each(function(d){
var threadnum = d3.select(this).attr("href");
threadnum = threadnum.substring(threadnum.indexOf(".") + 1, threadnum.lastIndexOf("/"));
if (isThreadIgnored(threadnum) && !showIgnThreads){
d3.select(this.parentNode.parentNode.parentNode.parentNode).style("display", "none");
totalcount -= 1;
}
});
d3.selectAll(".noteRow").each(function(d){
d3.select(this.parentNode).remove(); // remove all children
});
if (totalcount == 0 && totalcount !== origcount){
var t = d3.select(".discussionListItems");
t.html(""); // remove all children
t.append("li").attr("class","discussionListItem")
.append("div").attr("class","noteRow").text("No unhidden items left.");
}
}
function addIgnoreUser(){
// only show on pages that are collection of threads, not the threads themselves
if(!document.location.href.includes("/threads/")){
return;
}
d3.selectAll(".privateControls").each(function(d){
var t = d3.select(this);
var t2 = t.append("a");
t2.classed("OverlayTrigger item control report additional additional-ignore-user", true);
t2.append("span");
var author = d3.select(this.parentNode.parentNode.parentNode).attr("data-author");
if (isUserIgnored(author))
t2.text("Unignore");
else
t2.text("Ignore");
t2.attr("author", author);
});
}
function addIgnoreUserFromProfile(){
// only show on pages that are collection of threads, not the threads themselves
if(!document.location.href.includes("/profile-posts")){
return;
}
d3.selectAll(".privateControls").each(function(d){
var t = d3.select(this);
var t2 = t.append("a");
t2.classed("OverlayTrigger item control report additional additional-ignore-user", true);
var author = d3.select(this.parentNode.parentNode.parentNode).attr("data-author");
if (isUserIgnored(author))
t2.text("Unignore");
else
t2.text("Ignore");
t2.attr("author", author);
});
}
function addIgnoreThread(){
var headers = d3.select(".sectionHeaders");
headers.append("dd").classed("lastPost additional additional-header", true).append("a").append("span").text("Ignore thread");
d3.selectAll(".discussionListItem").each(function(d){
var t = d3.select(this);
var tID = t.attr("id");
var realThread = true;
if (tID != null){
tID = tID.substring(7);
var t2 = t.append("div");
t2.classed("listBlock lastPost additional additional-ignore-thread",true);
if (isThreadIgnored(tID))
t2.text("Unignore thread");
else
t2.text("Ignore thread");
t2.attr("threadID",tID);
}
});
}
function addIgnoreThreadButton(){
if(!document.location.href.includes("/threads/")){
return;
}
var link = d3.select(".linkGroup").append("a");
// get thread ID
var tID = document.location.href;
tID = tID.substring(tID.lastIndexOf(".") + 1);
tID = tID.substring(0, tID.indexOf("/"));
link.attr("threadID", tID);
if (isThreadIgnored(tID))
link.text("Unignore thread");
else
link.text("Ignore thread");
link.classed("additional-ignore-thread",true);
}
function addUnignoreUsersButton(){
// only show on pages that are collection of threads, not the threads themselves
if(!document.location.href.includes("/threads/") && !document.location.href.includes("/profile-posts")){
return;
}
var showIgnUsers = GM_getValue("showIgnoredUsers", false);
var unignore = d3.select(".linkGroup").append("a");
if (!showIgnUsers)
unignore.text("Show ignored users");
else
unignore.text("Don't show ignored users");
unignore.on("click", function(d){
GM_setValue("showIgnoredUsers",!showIgnUsers);
document.location.reload();
});
}
function addUnignoreThreadButton(){
// only show on pages that are collection of threads, not the threads themselves
if(document.location.href.includes("/threads/") || document.location.href.includes("/profile-posts")){
return;
}
var showIgnThreads = GM_getValue("showIgnoredThreads", false);
var unignore = d3.select(".linkGroup").append("a");
if (!showIgnThreads)
unignore.text("Show ignored threads");
else
unignore.text("Don't show ignored threads");
unignore.on("click", function(d){
GM_setValue("showIgnoredThreads",!showIgnThreads);
document.location.reload();
});
}
function makeClickable(){
d3.selectAll(".additional-ignore-user").style("cursor","pointer").on("click", function(d){
var author = d3.select(this).attr("author");
var wankers = GM_getValue("userIDs",[]);
if (isUserIgnored(author)){
wankers = wankers.filter(function(val,index, arr){
return val !== author;
});
}
else
wankers.push(author);
GM_setValue("userIDs",wankers);
document.location.reload();
});
d3.selectAll(".additional-ignore-thread").style("cursor","pointer").on("click", function(d){
var tID = d3.select(this).attr("threadID");
var threadIDs = GM_getValue("threadIDs",[]);
if (isThreadIgnored(tID))
threadIDs = threadIDs.filter(function(val,index, arr){
return val !== tID;
});
else
threadIDs.push(tID);
GM_setValue("threadIDs",threadIDs);
document.location.reload();
});
}
(function() {
ignore();
addIgnoreUser();
addIgnoreThread();
addIgnoreThreadButton();
addUnignoreThreadButton();
addUnignoreUsersButton();
addIgnoreUserFromProfile();
// make buttons functional
makeClickable();
})();