old thread became inactive
Code
// ==UserScript==
// @name dpuqb - d2jsp Post und Query Blocker / Lapdance http://forums.d2jsp.org/topic.php?t=70135916&f=149&o=60
// @version 2.0.5
// @namespace postblocker
// @include http://forums.d2jsp.org/topic.php?t=*&f=*
// @include https://forums.d2jsp.org/topic.php?t=*&f=*
// @include http://forums.d2jsp.org/topic.php?t=*
// @include https://forums.d2jsp.org/topic.php?t=*
// @include http://forums.d2jsp.org/forum.php?f=*
// @include https://forums.d2jsp.org/forum.php?f=*
// @include http://forums.d2jsp.org/track.php
// @include https://forums.d2jsp.org/track.php
// @include http://forums.d2jsp.org/guild.php?t=*
// @include https://forums.d2jsp.org/guild.php?t=*
// @author Lapdance => Prophets
// @description Remove all posts and quotes from users on d2jsp
// @require http://code.jquery.com/jquery-3.2.1.min.js
// @homepage http://forums.d2jsp.org/topic.php?t=70135916&f=149
// @icon http://i.imgur.com/lt2jblX.png
// @grant GM_deleteValue
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_listValues
// ==/UserScript==
//changelog
/*
v2.0.5
remove notification and body changing styles
v2.0.4
remove notification-display, thanks njag..
v2.0.3
added body width 100vw style, thanks njag..
v2.0.2
alter includes, get specific here, add https includes
credit to 0x00 ( http://forums.d2jsp.org/user.php?i=1081064 )
v2.0.1
init
*/
//script is db based, no need to edit any values in here.
//script adds links zo users in threads, so you can block them via link.
var gmKick = GM_listValues();
console.log("blocked users:", gmKick);
//dont use docready! just do it.
kickPosts();
kickThreads();
buildOptions();
addStyles();
if ($("body > dl > dt").length === 0) {
//add block links to users in threads
$("dl > dt > a").each(function(i, e) {
$(e).after(
$(document.createElement("a"))
.addClass("blockUserInThread")
.attr("data-user", $(e).text())
.attr("data-thread", getLocation())
.css("cursor", "pointer")
.text("thread")
);
$(e).after($(document.createElement("span")).html(" / "));
$(e).after(
$(document.createElement("a"))
.addClass("blockUser")
.attr("data-user", $(e).text())
.css("cursor", "pointer")
.text("global")
);
$(e).after($(document.createElement("span")).html(" – block: "));
});
}
function addStyles() {
var s = $(document.createElement("style"));
var css =
//"body { max-width: 100vw; }" +
//".npst { display: none; } " +
".unblockUser { float: left; padding: 5px; border: 1px dashed #345487; margin: 5px; }";
s.html(css);
$("head").append(s);
}
function buildOptions() {
//toggle
var toggleOptions = $(document.createElement("li"));
toggleOptions.append(
$(document.createElement("a"))
.attr("style", "cursor: pointer;")
.addClass("showOptions")
.text("Postblocker")
);
$(".barR").prepend(toggleOptions);
//hidden div containing the blocklist
var hiddenDiv = $(document.createElement("div")).addClass("optionsContainer");
hiddenDiv.css("display", "none");
hiddenDiv.css("position", "fixed");
hiddenDiv.css("padding", "20px");
hiddenDiv.css("width", "750px");
hiddenDiv.css("max-width", "80vw");
hiddenDiv.css("height", "500px");
hiddenDiv.css("maxheight", "80vh");
hiddenDiv.css("left", "50%");
hiddenDiv.css("top", "0");
hiddenDiv.css("transform", "translate(-50%)");
hiddenDiv.css("overflow-y", "auto");
hiddenDiv.css("background-color", "#ddd");
hiddenDiv.css("color", "#333");
hiddenDiv.css("z-index", "9001");
hiddenDiv.css("border", "1px solid #333");
hiddenDiv.css("border-top", "none");
hiddenDiv.css("border-bottom-right-radius", "10px");
hiddenDiv.css("border-bottom-left-radius", "10px");
var optionsDiv = $(document.createElement("div")).addClass("optionsDiv");
gmKick.forEach(function(val) {
if (
val != "chkremovePosts" &&
val != "chkremoveThreads" &&
val != "chkenableToggleRemovedQuotes" &&
val != "chkPassAufDasKartenhausVonAndreasAuf" &&
val != "chkDubs"
)
optionsDiv.html(optionsDiv.html() + '<div class="unblockUser" data-user="' + val + '" style="cursor: pointer;" title="">[' + val + "]</div>");
});
optionsDiv.html(optionsDiv.html().substr(0, optionsDiv.html().length - 2));
hiddenDiv.html(optionsDiv);
var closeOptions = $(document.createElement("div")).addClass("hideOptions");
closeOptions.css("position", "absolute");
closeOptions.css("right", "0");
closeOptions.css("top", "0");
closeOptions.css("padding", "5px");
closeOptions.css("font-size", "16px");
closeOptions.css("cursor", "pointer");
closeOptions.html("X");
hiddenDiv.append(closeOptions);
$("body").append(hiddenDiv);
}
function kickPosts() {
$.each(gmKick, function(i, v) {
if (v.indexOf("@") > -1) {
var vu = v.split("@")[0];
var vt = v.split("@")[1];
if (window.location.href.indexOf(vt) > -1) {
$("a:contains(" + vu + ")")
.parent("dt")
.parent("dl")
.remove();
$("a:contains(" + vu + ")")
.parent("dt")
.parent("dl")
.closest("tr")
.remove();
var html = $("div:contains(" + vu + ")")
.next(".quote2")
.html();
$("div:contains(" + vu + ")")
.next(".quote2")
.remove();
$("div.quote1:contains(" + vu + ")").replaceWith(
'<div class="dpuqb"><span><i>post contains blocked Quote ( by <a style="cursor:pointer;">' +
v +
'</a> )</i><hr style="border-color: crimson;"/></span><span style="padding-top:5px; display: none;">' +
html +
"</span>"
);
}
} else {
$("a:contains(" + v + ")")
.parent("dt")
.parent("dl")
.remove();
$("a:contains(" + v + ")")
.parent("dt")
.parent("dl")
.closest("tr")
.remove();
var html = $("div:contains(" + v + ")")
.next(".quote2")
.html();
$("div:contains(" + v + ")")
.next(".quote2")
.remove();
$("div.quote1:contains(" + v + ")").replaceWith(
'<div class="dpuqb"><span><i>d2post contains blocked Quote ( by <a style="cursor:pointer;">' +
v +
'</a> )</i><hr style="border-color: crimson;"/></span><span style="padding-top:5px; display: none;">' +
html +
"</span>"
);
}
});
}
function kickThreads() {
$.each(gmKick, function(i, v) {
$("tbody > tr > td:nth-child(3) > a:contains(" + v + ")")
.parent("td")
.each(function() {
if ($(this).hasClass("lc")) {
console.log("n");
} else {
$(this)
.parent("tr")
.remove();
console.log("removing thread");
}
});
});
}
function getLocation() {
var loc = window.location.href;
if (loc.indexOf("&o=") > -1) {
loc = loc.split("&o=")[0];
}
return loc;
}
$(".blockUser").click(function() {
var user = $(this).attr("data-user");
if (confirm("Block " + user + "?")) {
return blockUser(user);
}
return false;
});
function blockUser(user) {
GM_setValue(user, 1);
location.reload();
}
$(".blockUserInThread").click(function() {
var user = $(this).attr("data-user");
var thread = $(this).attr("data-thread");
if (confirm("Block " + user + " in thread " + thread + "?")) {
return blockUserInThread(user, thread);
}
return false;
});
function blockUserInThread(user, thread) {
GM_setValue(user + "@" + thread, 1);
location.reload();
}
$(".unblockUser").click(function() {
var user = $(this).attr("data-user");
if (confirm("Unblock " + user + "?")) {
return unblockUser(user, $(this));
}
return false;
});
function unblockUser(user, elem) {
GM_deleteValue(user, 1);
elem.remove();
}
$(".dpuqb a").click(function() {
$(this)
.parent("i")
.parent("span")
.parent(".dpuqb")
.children("span:last-child")
.toggle(0);
});
$(".showOptions, .hideOptions").click(function() {
console.log("options!");
$(".optionsContainer").toggle(0);
});
https://pastebin.com/1NwwxgxP