Author: Ph0X Language: javascript
Description: Not specified Timestamp: 2013-06-04 22:07:12 +0000
View raw paste Reply
  1. // ==UserScript==
  2. // @name       Brickwall Blocker
  3. // @namespace  ph0xwalled
  4. // @version    0.4
  5. // @description  Filters a specific word from what.cd forums
  6. // @match      https://what.cd/forums.php?*
  7. // @match      https://what.cd/torrents.php?*
  8. // @copyright  2013
  9. // ==/UserScript==
  10.  
  11. // List of banned words which can be modified
  12. banned_words = ["brickwall","bocsucks"];
  13.  
  14. // Uses xpath to grab all the posts
  15. var query = '//table[contains(@class, "forum_post")]';
  16. var postIter = document.evaluate(query, document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
  17. var post = postIter.iterateNext();
  18.  
  19. while (post != null){
  20.     // Adds event to collapse post when clicking the top
  21.     var top = post.children[1].children[0];
  22.     top.addEventListener('click', togglePost, false);
  23.    
  24.     // Grabs the text of the post
  25.     var text = post.children[1].children[1].children[1].children[0].innerText.toLowerCase();
  26.    
  27.     // Checks if it contains any banned words
  28.     for (var i=0; i<banned_words.length; i++)
  29.         if (text.indexOf(banned_words[i]) != -1)        
  30.             top.click(); // Collapses the post
  31.        
  32.         post = postIter.iterateNext(); // Grabs the next post
  33. }
  34.  
  35. // Toggles the visibility of a post
  36. function togglePost(e){
  37.     if (e.srcElement.tagName != "TD")
  38.         return;
  39.    
  40.         var bottom = this.parentNode.parentNode.children[1].children[1];
  41.     if (bottom.style.display == "none")
  42.         bottom.style.display = "";
  43.     else
  44.         bottom.style.display = "none";
  45. }
View raw paste Reply