Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name dpuqb - d2jsp Post und Query Blocker / Lapdance http://forums.d2jsp.org/topic.php?t=70135916&f=149&o=60
- // @version 0.3.5
- // @namespace postblocker
- // @include http://forums.d2jsp.org/forum.php?f=149
- // @include http://forums.d2jsp.org/topic.php?t=*&f=149*
- // @include http://forums.d2jsp.org/guild.php?*
- // @author Lapdance => Prophets
- // @description Remove all posts and quotes from users on d2jsp
- // @require http://code.jquery.com/jquery-latest.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
- /*
- 0.3.5
- fixed a bug where topics would be removed if a blocked user was the last poster in it (only applied to "pinned" topics)
- 0.3.4
- merged ff branch, including only GERSUB and GUILDCHAT for now, fixing more stuff in the future.
- 0.3.3f
- introduced firefox-version, may not be compatible with chrome. (grease/tampermonkey stuff...)
- 0.3.3
- fixes to @grants
- 0.3.2c
- fixed kartenhaus-pos
- 0.3.2
- added funSettings (andreas' kartenhaus 0.1, dubs/trips/quds), slight style-changes
- */
- //logic, better dont touch this
- var removeThreads = GM_getValue("chkremoveThreads");
- var removePosts = GM_getValue("chkremovePosts");
- var enableToggleRemovedQuotes = GM_getValue("chkenableToggleRemovedQuotes");
- var passAufDasKartenhausVonAndreasAuf = GM_getValue("chkPassAufDasKartenhausVonAndreasAuf");
- var dubs = GM_getValue("chkDubs");
- //new functionality, db based
- var gmKick = GM_listValues();
- $('dl > dt > a').each(function() { //append in reverse order
- var nick = $(this).text();
- var isBlocked = false;
- for each (var val in gmKick) {
- if(val == nick)
- isBlocked = true;
- }
- if(!isBlocked) {
- $(this).after($(document.createElement('a')).attr('data-nick', nick).addClass('dpuqb-block').css('cursor','pointer').text("block"));
- $(this).after($(document.createElement('span')).html(" - "));
- }
- });
- $.each( gmKick, function( i, v ) {
- //threads
- if(removeThreads) {
- $("tbody > tr > td:nth-child(3) > a:contains("+v+")").parent('td').each(function() {
- if($(this).hasClass('lc')) {
- } else {
- $(this).parent('tr').remove();
- }
- });
- }
- //posts
- if(removePosts) {
- $("a:contains("+v+")").parent('dt').parent('dl').remove();
- $("a:contains("+v+")").parent('dt').parent('dl').closest('tr').remove();
- var text = $("div:contains("+v+")").next('.quote2').text();
- $("div:contains("+v+")").next('.quote2').remove();
- if(enableToggleRemovedQuotes) {
- $("div.quote1:contains("+v+")").replaceWith('<div id="dpuqb" style="max-width:50vw; right:10px;position:absolute; text-align:right;"><span><i>d2jsp Post und Query Blocker - post contains blocked Quote ( by <a style="cursor:pointer;">'+v+'</a> )</i><hr style="border-color: crimson;"/></span><span style="padding:5px; line-height:20px;background-color:rgba(244,244,244,1);display: none;">'+text+'</span>');
- }
- }
- });
- if(dubs) {
- var style = $(document.createElement('style')).html("span.doubles { }"+
- "span.doubles:before{ content: ' DOUBLES '; color: green; font-size: 1.5em; }"+
- "span.doubles:after{ content: ' DOUBLES'; color: green; font-size: 1.5em; }"+
- "span.triples { }"+
- "span.triples:before { content: ' TRIPLES '; color: orange; font-size: 2em; }"+
- "span.triples:after { content: ' TRIPLES'; color: orange; font-size: 2em; }"+
- "span.quadruples { }"+
- "span.quadruples:before { content: ' QUADRUPLES '; color: red; font-size: 3em; }"+
- "span.quadruples:after { content: ' QUADRUPLES'; color: red; font-size: 3em; }"+
- "");
- $('head').append(style);
- $('dd > div.desc.p3 > a').each(function() {
- var elem = $(this);
- var id = elem.attr('href').match(/\d+/)[0];
- var addElem = $(document.createElement('span')).html(" " + id);
- if(hasDoubles(id)) {
- if(hasTriples(id)) {
- if(hasQuadruples(id)) {
- addElem.addClass("quadruples");
- } else {
- addElem.addClass("triples");
- }
- } else {
- addElem.addClass("doubles");
- }
- }
- elem.after(addElem);
- });
- }
- $(document).ready(function() {
- if($('body > dl > dt').length > 0) {
- displayBlockList();
- displayFunSettings();
- }
- if(enableToggleRemovedQuotes) {
- $('#dpuqb > span > i > a').on('click', function() {
- $(this).parent('i').parent('span').next('span').toggle();
- });
- }
- $('.dpuqb-block').on('click', function() {
- var nick = $(this).attr('data-nick');
- var c = confirm("Block " + nick + "?");
- if(c) {
- GM_setValue(nick,1);
- location.reload();
- }
- });
- $('.dpuqb-unblock').on('click', function() {
- var nick = $(this).attr('data-nick');
- var c = confirm("Unblock " + nick + "?");
- if(c) {
- GM_deleteValue(nick,1);
- location.reload();
- }
- });
- $('.dpuqb-chk').on('change', function(a, b, c) {
- if($(this).is(':checked')){
- switch($(this).attr('id')) {
- case "chkremovePosts":
- GM_setValue("chkremovePosts", true);
- break;
- case "chkremoveThreads":
- GM_setValue("chkremoveThreads", true);
- location.reload();
- break;
- case "chkenableToggleRemovedQuotes":
- GM_setValue("chkenableToggleRemovedQuotes", true);
- break;
- case "chkDubs":
- GM_setValue("chkDubs", true);
- break;
- case "chkPassAufDasKartenhausVonAndreasAuf":
- GM_setValue("chkPassAufDasKartenhausVonAndreasAuf", true);
- location.reload();
- break;
- default:
- break;
- }
- } else {
- switch($(this).attr('id')) {
- case "chkremovePosts":
- GM_setValue("chkremovePosts", false);
- break;
- case "chkremoveThreads":
- GM_setValue("chkremoveThreads", false);
- location.reload();
- break;
- case "chkenableToggleRemovedQuotes":
- GM_setValue("chkenableToggleRemovedQuotes", false);
- break;
- case "chkDubs":
- GM_setValue("chkDubs", false);
- break;
- case "chkPassAufDasKartenhausVonAndreasAuf":
- GM_setValue("chkPassAufDasKartenhausVonAndreasAuf", false);
- location.reload();
- break;
- default:
- break;
- }
- }
- });
- $('#dpuqb-blockList-toggle').on('click', function() {
- $('body > dl:nth-child(5) > table').toggle("slow");
- });
- $('#dpuqb-randomStuff-toggle').on('click', function() {
- $('body > dl:nth-child(4) > table').toggle("slow");
- });
- });
- //functions
- function displayFunSettings() {
- var dl = $(document.createElement('dl'));
- var dt = $(document.createElement('dt')).css('border','1px solid #4372A0').html('<span id="dpuqb-randomStuff-toggle" style="cursor: pointer;">dpuqb - random stuff</span>');
- var table = $(document.createElement('table')).addClass('ftb').css('display','none');
- var tbody = $(document.createElement('tbody'));
- var tr1 = $(document.createElement('tr'));
- var chkPassAufDasKartenhausVonAndreasAuf = "";
- var chkDubs = "";
- if(GM_getValue("chkPassAufDasKartenhausVonAndreasAuf"))
- chkPassAufDasKartenhausVonAndreasAuf = "checked";
- if(GM_getValue("chkDubs"))
- chkDubs = "checked";
- var settings = '<input type="checkbox" name="checkbox" class="dpuqb-chk" id="chkDubs" '+chkDubs+'> '+
- '<label for="chkDubs">dubs, trips, quadruples ...</label>'+
- '<br />'+
- '<input type="checkbox" name="checkbox" class="dpuqb-chk" id="chkPassAufDasKartenhausVonAndreasAuf" '+chkPassAufDasKartenhausVonAndreasAuf+'> '+
- '<label for="chkPassAufDasKartenhausVonAndreasAuf">passAufDasKartenhausVonAndreasAuf</label>'+
- //'<br />'+
- '';
- var th = $(document.createElement('th')).attr('align','left').attr('width','100%').html(settings);
- var tr2 = $(document.createElement('tr'));
- var td = $(document.createElement('td')).css('padding','2px 3px').css('border','1px dashed #a1d0ff');
- if(GM_getValue("chkPassAufDasKartenhausVonAndreasAuf")) {
- var t = $(document.createElement('div'));
- var top = parseInt($('body > div.head').height()) + parseInt($('body > div.bar').height());
- t.css('position','absolute').css('right','30px').css('top',top+30+'px');
- t.html('<span style="color:#fff">.....</span>/\\<br />' +
- '<span style="color:#fff">....</span>/\\/\\<br />'+
- '<span style="color:#fff">...</span>/\\/\\/\\<br />'+
- '<span style="color:#fff">..</span>/\\/\\/\\/\\');
- $('body').append(t);
- }
- tr2.append(td);
- tr1.append(th);
- tbody.append(tr1).append(tr2);
- table.append(tbody);
- dl.append(dt);
- dl.append(table);
- $('body > dl > dt').eq(0).parent().before(dl);
- }
- function displayBlockList() {
- var dl = $(document.createElement('dl'));
- var dt = $(document.createElement('dt')).css('border','1px solid #4372A0').html('<span id="dpuqb-blockList-toggle" style="cursor: pointer;">dpuqb - manage block-list</span>');
- var table = $(document.createElement('table')).addClass('ftb').css('display','none');
- var tbody = $(document.createElement('tbody'));
- var tr1 = $(document.createElement('tr'));
- var chkremovePosts = "";
- var chkremoveThreads = "";
- var chkenableToggleRemovedQuotes = "";
- var chkPassAufDasKartenhausVonAndreasAuf = "";
- if(GM_getValue("chkremovePosts"))
- chkremovePosts = "checked";
- if(GM_getValue("chkremoveThreads"))
- chkremoveThreads = "checked";
- if(GM_getValue("chkenableToggleRemovedQuotes"))
- chkenableToggleRemovedQuotes = "checked";
- var settings = '<input type="checkbox" name="checkbox" class="dpuqb-chk" id="chkremovePosts" '+chkremovePosts+'> '+
- '<label for="chkremovePosts">remove Posts</label>'+
- '<br />'+
- '<input type="checkbox" name="checkbox" class="dpuqb-chk" id="chkremoveThreads" '+chkremoveThreads+'> '+
- '<label for="chkremoveThreads">remove Threads</label>'+
- '<br />'+
- '<input type="checkbox" name="checkbox" class="dpuqb-chk" id="chkenableToggleRemovedQuotes" '+chkenableToggleRemovedQuotes+'> '+
- '<label for="chkenableToggleRemovedQuotes">enableToggleRemovedQuotes</label>'+
- //'<br />'+
- '';
- var th = $(document.createElement('th')).attr('align','left').attr('width','100%').html(settings);
- var tr2 = $(document.createElement('tr'));
- var td = $(document.createElement('td')).css('padding','2px 3px').css('border','1px dashed #a1d0ff');;
- for each (var val in gmKick) {
- if(val != "chkremovePosts" && val != "chkremoveThreads" && val !="chkenableToggleRemovedQuotes" && val !="chkPassAufDasKartenhausVonAndreasAuf" && val !="chkDubs")
- td.html(td.html() + '<a class="dpuqb-unblock" data-nick="'+val+'" style="cursor: pointer;" title="">['+val+']</a>, ');
- }
- td.html(td.html().substr(0, td.html().length-2));
- tr2.append(td);
- tr1.append(th);
- tbody.append(tr1).append(tr2);
- table.append(tbody);
- dl.append(dt);
- dl.append(table);
- $('body > dl > dt').eq(0).parent().before(dl);
- }
- function hasDoubles(id) {
- if(parseInt(id.substr(id.length -2, 1)) == parseInt(id.substr(id.length - 1, 1))) {
- console.log("hasDoubles("+id+") = true("+id.substr(id.length -2, 1) + id.substr(id.length -1, 1)+")");
- return true;
- }
- console.log("hasDoubles("+id+") = false("+id.substr(id.length -2, 1) + id.substr(id.length -1, 1)+")");
- return false;
- }
- function hasTriples(id) {
- if((parseInt(id.substr(id.length -3, 1)) == parseInt(id.substr(id.length - 2, 1))) && (parseInt(id.substr(id.length - 2, 1)) == parseInt(id.substr(id.length - 1, 1)))) {
- console.log("hasTriples("+id+") = true("+id.substr(id.length -3, 1) + id.substr(id.length -2, 1) + id.substr(id.length -1, 1)+")");
- return true;
- }
- console.log("hasTriples("+id+") = false("+id.substr(id.length -3, 1) + id.substr(id.length -2, 1) + id.substr(id.length -1, 1)+")");
- return false;
- }
- function hasQuadruples(id) {
- if((parseInt(id.substr(id.length -4, 1)) == parseInt(id.substr(id.length - 3, 1))) && (parseInt(id.substr(id.length -3, 1)) == parseInt(id.substr(id.length - 2, 1))) && (parseInt(id.substr(id.length - 2, 1)) == parseInt(id.substr(id.length - 1, 1)))) {
- console.log("hasTriples("+id+") = true("+id.substr(id.length -4, 1) + id.substr(id.length -3, 1) + id.substr(id.length -2, 1) + id.substr(id.length -1, 1)+")");
- return true;
- }
- console.log("hasTriples("+id+") = false("+id.substr(id.length -4, 1) + id.substr(id.length -3, 1) + id.substr(id.length -2, 1) + id.substr(id.length -1, 1)+")");
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement