Advertisement
Guest User

4prone

a guest
Apr 29th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.09 KB | None | 0 0
  1. // ==UserScript==
  2. // @name dpuqb - d2jsp Post und Query Blocker / Lapdance http://forums.d2jsp.org/topic.php?t=70135916&f=149&o=60
  3. // @version 0.3.5
  4. // @namespace postblocker
  5. // @include http://forums.d2jsp.org/forum.php?f=149
  6. // @include http://forums.d2jsp.org/topic.php?t=*&f=149*
  7. // @include http://forums.d2jsp.org/guild.php?*
  8. // @author Lapdance => Prophets
  9. // @description Remove all posts and quotes from users on d2jsp
  10. // @require http://code.jquery.com/jquery-latest.js
  11. // @homepage http://forums.d2jsp.org/topic.php?t=70135916&f=149
  12. // @icon http://i.imgur.com/lt2jblX.png
  13. // @grant GM_deleteValue
  14. // @grant GM_getValue
  15. // @grant GM_setValue
  16. // @grant GM_listValues
  17. // ==/UserScript==
  18.  
  19. //changelog
  20. /*
  21.  
  22. 0.3.5
  23. fixed a bug where topics would be removed if a blocked user was the last poster in it (only applied to "pinned" topics)
  24.  
  25. 0.3.4
  26. merged ff branch, including only GERSUB and GUILDCHAT for now, fixing more stuff in the future.
  27.  
  28. 0.3.3f
  29. introduced firefox-version, may not be compatible with chrome. (grease/tampermonkey stuff...)
  30.  
  31. 0.3.3
  32. fixes to @grants
  33.  
  34. 0.3.2c
  35. fixed kartenhaus-pos
  36.  
  37. 0.3.2
  38. added funSettings (andreas' kartenhaus 0.1, dubs/trips/quds), slight style-changes
  39.  
  40. */
  41.  
  42.  
  43. //logic, better dont touch this
  44. var removeThreads = GM_getValue("chkremoveThreads");
  45. var removePosts = GM_getValue("chkremovePosts");
  46. var enableToggleRemovedQuotes = GM_getValue("chkenableToggleRemovedQuotes");
  47. var passAufDasKartenhausVonAndreasAuf = GM_getValue("chkPassAufDasKartenhausVonAndreasAuf");
  48. var dubs = GM_getValue("chkDubs");
  49.  
  50. //new functionality, db based
  51. var gmKick = GM_listValues();
  52.  
  53. $('dl > dt > a').each(function() { //append in reverse order
  54. var nick = $(this).text();
  55.  
  56. var isBlocked = false;
  57. for each (var val in gmKick) {
  58. if(val == nick)
  59. isBlocked = true;
  60. }
  61. if(!isBlocked) {
  62. $(this).after($(document.createElement('a')).attr('data-nick', nick).addClass('dpuqb-block').css('cursor','pointer').text("block"));
  63. $(this).after($(document.createElement('span')).html(" - "));
  64. }
  65. });
  66.  
  67. $.each( gmKick, function( i, v ) {
  68. //threads
  69. if(removeThreads) {
  70. $("tbody > tr > td:nth-child(3) > a:contains("+v+")").parent('td').each(function() {
  71. if($(this).hasClass('lc')) {
  72.  
  73. } else {
  74. $(this).parent('tr').remove();
  75. }
  76. });
  77. }
  78.  
  79. //posts
  80. if(removePosts) {
  81. $("a:contains("+v+")").parent('dt').parent('dl').remove();
  82. $("a:contains("+v+")").parent('dt').parent('dl').closest('tr').remove();
  83. var text = $("div:contains("+v+")").next('.quote2').text();
  84. $("div:contains("+v+")").next('.quote2').remove();
  85. if(enableToggleRemovedQuotes) {
  86. $("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>');
  87. }
  88. }
  89. });
  90.  
  91. if(dubs) {
  92. var style = $(document.createElement('style')).html("span.doubles { }"+
  93. "span.doubles:before{ content: ' DOUBLES '; color: green; font-size: 1.5em; }"+
  94. "span.doubles:after{ content: ' DOUBLES'; color: green; font-size: 1.5em; }"+
  95.  
  96. "span.triples { }"+
  97. "span.triples:before { content: ' TRIPLES '; color: orange; font-size: 2em; }"+
  98. "span.triples:after { content: ' TRIPLES'; color: orange; font-size: 2em; }"+
  99.  
  100. "span.quadruples { }"+
  101. "span.quadruples:before { content: ' QUADRUPLES '; color: red; font-size: 3em; }"+
  102. "span.quadruples:after { content: ' QUADRUPLES'; color: red; font-size: 3em; }"+
  103.  
  104. "");
  105. $('head').append(style);
  106.  
  107. $('dd > div.desc.p3 > a').each(function() {
  108.  
  109. var elem = $(this);
  110. var id = elem.attr('href').match(/\d+/)[0];
  111.  
  112. var addElem = $(document.createElement('span')).html("&nbsp;" + id);
  113.  
  114. if(hasDoubles(id)) {
  115. if(hasTriples(id)) {
  116. if(hasQuadruples(id)) {
  117. addElem.addClass("quadruples");
  118. } else {
  119. addElem.addClass("triples");
  120. }
  121. } else {
  122. addElem.addClass("doubles");
  123. }
  124. }
  125.  
  126. elem.after(addElem);
  127. });
  128. }
  129.  
  130. $(document).ready(function() {
  131. if($('body > dl > dt').length > 0) {
  132. displayBlockList();
  133. displayFunSettings();
  134. }
  135.  
  136. if(enableToggleRemovedQuotes) {
  137. $('#dpuqb > span > i > a').on('click', function() {
  138. $(this).parent('i').parent('span').next('span').toggle();
  139. });
  140. }
  141.  
  142. $('.dpuqb-block').on('click', function() {
  143. var nick = $(this).attr('data-nick');
  144. var c = confirm("Block " + nick + "?");
  145.  
  146. if(c) {
  147. GM_setValue(nick,1);
  148. location.reload();
  149. }
  150. });
  151. $('.dpuqb-unblock').on('click', function() {
  152. var nick = $(this).attr('data-nick');
  153. var c = confirm("Unblock " + nick + "?");
  154. if(c) {
  155. GM_deleteValue(nick,1);
  156. location.reload();
  157. }
  158. });
  159. $('.dpuqb-chk').on('change', function(a, b, c) {
  160. if($(this).is(':checked')){
  161. switch($(this).attr('id')) {
  162. case "chkremovePosts":
  163. GM_setValue("chkremovePosts", true);
  164. break;
  165. case "chkremoveThreads":
  166. GM_setValue("chkremoveThreads", true);
  167. location.reload();
  168. break;
  169. case "chkenableToggleRemovedQuotes":
  170. GM_setValue("chkenableToggleRemovedQuotes", true);
  171. break;
  172. case "chkDubs":
  173. GM_setValue("chkDubs", true);
  174. break;
  175. case "chkPassAufDasKartenhausVonAndreasAuf":
  176. GM_setValue("chkPassAufDasKartenhausVonAndreasAuf", true);
  177. location.reload();
  178. break;
  179. default:
  180. break;
  181. }
  182. } else {
  183. switch($(this).attr('id')) {
  184. case "chkremovePosts":
  185. GM_setValue("chkremovePosts", false);
  186. break;
  187. case "chkremoveThreads":
  188. GM_setValue("chkremoveThreads", false);
  189. location.reload();
  190. break;
  191. case "chkenableToggleRemovedQuotes":
  192. GM_setValue("chkenableToggleRemovedQuotes", false);
  193. break;
  194. case "chkDubs":
  195. GM_setValue("chkDubs", false);
  196. break;
  197. case "chkPassAufDasKartenhausVonAndreasAuf":
  198. GM_setValue("chkPassAufDasKartenhausVonAndreasAuf", false);
  199. location.reload();
  200. break;
  201. default:
  202. break;
  203. }
  204. }
  205. });
  206. $('#dpuqb-blockList-toggle').on('click', function() {
  207. $('body > dl:nth-child(5) > table').toggle("slow");
  208. });
  209. $('#dpuqb-randomStuff-toggle').on('click', function() {
  210. $('body > dl:nth-child(4) > table').toggle("slow");
  211. });
  212. });
  213.  
  214.  
  215. //functions
  216. function displayFunSettings() {
  217. var dl = $(document.createElement('dl'));
  218. var dt = $(document.createElement('dt')).css('border','1px solid #4372A0').html('<span id="dpuqb-randomStuff-toggle" style="cursor: pointer;">dpuqb - random stuff</span>');
  219. var table = $(document.createElement('table')).addClass('ftb').css('display','none');
  220. var tbody = $(document.createElement('tbody'));
  221. var tr1 = $(document.createElement('tr'));
  222.  
  223. var chkPassAufDasKartenhausVonAndreasAuf = "";
  224. var chkDubs = "";
  225. if(GM_getValue("chkPassAufDasKartenhausVonAndreasAuf"))
  226. chkPassAufDasKartenhausVonAndreasAuf = "checked";
  227. if(GM_getValue("chkDubs"))
  228. chkDubs = "checked";
  229.  
  230. var settings = '<input type="checkbox" name="checkbox" class="dpuqb-chk" id="chkDubs" '+chkDubs+'>&nbsp;'+
  231. '<label for="chkDubs">dubs, trips, quadruples ...</label>'+
  232. '<br />'+
  233.  
  234. '<input type="checkbox" name="checkbox" class="dpuqb-chk" id="chkPassAufDasKartenhausVonAndreasAuf" '+chkPassAufDasKartenhausVonAndreasAuf+'>&nbsp;'+
  235. '<label for="chkPassAufDasKartenhausVonAndreasAuf">passAufDasKartenhausVonAndreasAuf</label>'+
  236. //'<br />'+
  237.  
  238. '';
  239. var th = $(document.createElement('th')).attr('align','left').attr('width','100%').html(settings);
  240. var tr2 = $(document.createElement('tr'));
  241. var td = $(document.createElement('td')).css('padding','2px 3px').css('border','1px dashed #a1d0ff');
  242.  
  243. if(GM_getValue("chkPassAufDasKartenhausVonAndreasAuf")) {
  244. var t = $(document.createElement('div'));
  245.  
  246. var top = parseInt($('body > div.head').height()) + parseInt($('body > div.bar').height());
  247.  
  248. t.css('position','absolute').css('right','30px').css('top',top+30+'px');
  249. t.html('<span style="color:#fff">.....</span>/\\<br />' +
  250. '<span style="color:#fff">....</span>/\\/\\<br />'+
  251. '<span style="color:#fff">...</span>/\\/\\/\\<br />'+
  252. '<span style="color:#fff">..</span>/\\/\\/\\/\\');
  253. $('body').append(t);
  254. }
  255.  
  256. tr2.append(td);
  257. tr1.append(th);
  258. tbody.append(tr1).append(tr2);
  259. table.append(tbody);
  260.  
  261. dl.append(dt);
  262. dl.append(table);
  263.  
  264. $('body > dl > dt').eq(0).parent().before(dl);
  265. }
  266. function displayBlockList() {
  267. var dl = $(document.createElement('dl'));
  268. var dt = $(document.createElement('dt')).css('border','1px solid #4372A0').html('<span id="dpuqb-blockList-toggle" style="cursor: pointer;">dpuqb - manage block-list</span>');
  269. var table = $(document.createElement('table')).addClass('ftb').css('display','none');
  270. var tbody = $(document.createElement('tbody'));
  271. var tr1 = $(document.createElement('tr'));
  272.  
  273. var chkremovePosts = "";
  274. var chkremoveThreads = "";
  275. var chkenableToggleRemovedQuotes = "";
  276. var chkPassAufDasKartenhausVonAndreasAuf = "";
  277. if(GM_getValue("chkremovePosts"))
  278. chkremovePosts = "checked";
  279. if(GM_getValue("chkremoveThreads"))
  280. chkremoveThreads = "checked";
  281. if(GM_getValue("chkenableToggleRemovedQuotes"))
  282. chkenableToggleRemovedQuotes = "checked";
  283.  
  284. var settings = '<input type="checkbox" name="checkbox" class="dpuqb-chk" id="chkremovePosts" '+chkremovePosts+'>&nbsp;'+
  285. '<label for="chkremovePosts">remove Posts</label>'+
  286. '<br />'+
  287.  
  288. '<input type="checkbox" name="checkbox" class="dpuqb-chk" id="chkremoveThreads" '+chkremoveThreads+'>&nbsp;'+
  289. '<label for="chkremoveThreads">remove Threads</label>'+
  290. '<br />'+
  291.  
  292. '<input type="checkbox" name="checkbox" class="dpuqb-chk" id="chkenableToggleRemovedQuotes" '+chkenableToggleRemovedQuotes+'>&nbsp;'+
  293. '<label for="chkenableToggleRemovedQuotes">enableToggleRemovedQuotes</label>'+
  294. //'<br />'+
  295.  
  296. '';
  297. var th = $(document.createElement('th')).attr('align','left').attr('width','100%').html(settings);
  298. var tr2 = $(document.createElement('tr'));
  299. var td = $(document.createElement('td')).css('padding','2px 3px').css('border','1px dashed #a1d0ff');;
  300.  
  301. for each (var val in gmKick) {
  302. if(val != "chkremovePosts" && val != "chkremoveThreads" && val !="chkenableToggleRemovedQuotes" && val !="chkPassAufDasKartenhausVonAndreasAuf" && val !="chkDubs")
  303. td.html(td.html() + '<a class="dpuqb-unblock" data-nick="'+val+'" style="cursor: pointer;" title="">['+val+']</a>, ');
  304. }
  305. td.html(td.html().substr(0, td.html().length-2));
  306.  
  307. tr2.append(td);
  308. tr1.append(th);
  309. tbody.append(tr1).append(tr2);
  310. table.append(tbody);
  311.  
  312. dl.append(dt);
  313. dl.append(table);
  314.  
  315. $('body > dl > dt').eq(0).parent().before(dl);
  316. }
  317. function hasDoubles(id) {
  318. if(parseInt(id.substr(id.length -2, 1)) == parseInt(id.substr(id.length - 1, 1))) {
  319. console.log("hasDoubles("+id+") = true("+id.substr(id.length -2, 1) + id.substr(id.length -1, 1)+")");
  320. return true;
  321. }
  322. console.log("hasDoubles("+id+") = false("+id.substr(id.length -2, 1) + id.substr(id.length -1, 1)+")");
  323. return false;
  324. }
  325. function hasTriples(id) {
  326. 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)))) {
  327. console.log("hasTriples("+id+") = true("+id.substr(id.length -3, 1) + id.substr(id.length -2, 1) + id.substr(id.length -1, 1)+")");
  328. return true;
  329. }
  330. console.log("hasTriples("+id+") = false("+id.substr(id.length -3, 1) + id.substr(id.length -2, 1) + id.substr(id.length -1, 1)+")");
  331. return false;
  332. }
  333. function hasQuadruples(id) {
  334. 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)))) {
  335. 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)+")");
  336. return true;
  337. }
  338. 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)+")");
  339. return false;
  340. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement