Advertisement
Guest User

Untitled

a guest
Jan 5th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           NeoGAF - Total Ignore
  3. // @namespace      neogaf
  4. // @description    Hides ignored users' posts totally, as well as text from posts that quote them (leaves option to display those posts)
  5. // @version        1.0
  6. // @icon           http://s3.amazonaws.com/uso_ss/icon/125952/large.png
  7. // @include        http://*neogaf.tld/forum/showthread.php*
  8. // ==/UserScript==
  9.  
  10. var SCORCHED_EARTH = true; // if true, totally remove posts that quote someone on ignore. Otherwise, they're just hidden, with an option to "show post"
  11.  
  12. var p = document.querySelectorAll('a[onclick*="display_post"]'), i = p.length;
  13. while (i--) {
  14.     p[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display = 'none';
  15. }
  16. GM_xmlhttpRequest({
  17.     method: "GET",
  18.     url: "profile.php?do=ignorelist",
  19.     onload: function(response){
  20.         var range = document.createRange();
  21.         range.selectNode(document.body);
  22.         var parsedhtml = document.createElement("div");
  23.         parsedhtml.style.display = "none";
  24.         parsedhtml.innerHTML = response.responseText;
  25.         document.body.appendChild(parsedhtml);
  26.         if(document.getElementById("ignorelist") != null)
  27.         {
  28.             var ignoreduserslinks = document.getElementById("ignorelist").getElementsByTagName("a");
  29.             var ignoredusers = [];
  30.             for(var i = 0; i < ignoreduserslinks.length; i++)
  31.                 ignoredusers.push(ignoreduserslinks[i].innerHTML);
  32.             // var quotes = document.getElementsByClassName("alt2");
  33.             var quotes = document.querySelectorAll('div[style*="margin:20px; margin-top:5px;"]');
  34.             console.log(ignoredusers);
  35.             for(var i = 0; i < quotes.length; i++)
  36.             {
  37.                 if(ignoredusers.indexOf(quotes[i].getElementsByTagName("strong")[0].innerHTML) != -1)
  38.                 {
  39.                     if(SCORCHED_EARTH)
  40.                     {
  41.                         quotes[i].parentNode.parentNode.parentNode.style.display = "none";
  42.                     }
  43.                     else
  44.                     {
  45.                         var post = quotes[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
  46.                         var extradiv = document.createElement("div");
  47.                         extradiv.innerHTML = post.innerHTML;
  48.                         extradiv.style.visibility = "hidden";
  49.                         post.innerHTML = "";
  50.                         var show = document.createElement("div");
  51.                         show.innerHTML = "---This post quotes ignored user, click to show---";
  52.                         show.style.textDecoration = "underline";
  53.                         show.style.cursor = "pointer";
  54.                         show.onclick = function(){
  55.                             this.nextSibling.style.visibility = "visible";
  56.                             this.style.display = "none";
  57.                         };
  58.                         post.appendChild(show);
  59.                         post.appendChild(extradiv);
  60.                     }
  61.                 }
  62.             }
  63.         }
  64.     }
  65. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement