fokse's d2jsp post blocker

Hides posts from a defined list of users [Update 03/03/2024]

  1. // ==UserScript==
  2. // @license MIT
  3. // @name fokse's d2jsp post blocker
  4. // @author Fokse
  5. // @description Hides posts from a defined list of users [Update 03/03/2024]
  6. // @namespace jsppostblocker
  7. // @include https://forums.d2jsp.org/topic.php?t=*&f=*
  8. // @include https://forums.d2jsp.org/topic.php?t=*
  9. // @include https://forums.d2jsp.org/post.php
  10. // @require http://code.jquery.com/jquery-latest.js
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @grant GM_deleteValue
  14. // @version 1.15
  15. // ==/UserScript==
  16.  
  17. if (!Array.isArray(GM_getValue("fokse_post_blocker_userlist"))) {
  18. GM_setValue("fokse_post_blocker_userlist", []);
  19. }
  20.  
  21. function parsePage(){
  22. console.log('sup');
  23. var blockedUser = GM_getValue('fokse_post_blocker_userlist')
  24.  
  25. $('body > form > dl').each(function() {
  26. if (typeof $('.pU > div > a', this).attr('href') !== 'undefined' && ~$('.pU > div > a', this).attr('href').indexOf('user.php?i=')) {
  27. var userId = $('.pU > div > a', this).attr('href').split("=")[1];
  28. if (~blockedUser.indexOf(userId)){
  29. $('dd > div > div.bc1.upc > div.desc.cl.rc > div.fR.links', this).prepend(`<b><a href="#" class="blockPost" action="unblock" userId="${userId}">Unblock Posts</a></b>`);
  30. $('dd > div > div.bc1.upc > .sig', this).hide();
  31. $('.pU', this).children().eq(1).hide()
  32. $('div.bts', this).html('<center><b><span style="color:#d65a5a;">Post from that user are hidden</style></b></center>');
  33. } else{
  34. $('dd > div > div.bc1.upc > div.desc.cl.rc > div.fR.links', this).prepend(`<b><a href="#" class="blockPost" action="block" userId="${userId}">Block Posts</a></b>`);
  35. }
  36. }
  37. });
  38.  
  39. $('.blockPost').click(function(){
  40. var blockedUser = GM_getValue('fokse_post_blocker_userlist'),
  41. userId = $(this).attr('userId');
  42.  
  43. if ($(this).attr('action') == "block" && !~blockedUser.indexOf(userId)){
  44. blockedUser.push(userId);
  45. }
  46. else if ($(this).attr('action') == "unblock" && ~blockedUser.indexOf(userId)){
  47. blockedUser.splice(blockedUser.indexOf(userId),1);
  48. }
  49.  
  50.  
  51. GM_setValue("fokse_post_blocker_userlist", blockedUser);
  52. location.reload();
  53. })
  54.  
  55. }
  56.  
  57. parsePage();