Advertisement
Guest User

Script

a guest
Jan 31st, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var ignoredUsers, expireAfter, opacity, TEN_YEARS_IN_MILLISECONDS, TWO_WEEKS_IN_MILLISECONDS;
  2.  
  3. TWO_WEEKS_IN_MILLISECONDS = 1209600000;
  4. expireAfter = TWO_WEEKS_IN_MILLISECONDS;
  5. opacity = '0.3';
  6.  
  7. ignoredUsers = window.localStorage.getItem("ignoredUsers");
  8. if (ignoredUsers) {
  9.     ignoredUsers = JSON.parse(ignoredUsers);
  10. } else {
  11.     ignoredUsers = {};
  12. }
  13.  
  14. //
  15.  
  16. function ignoreUser(uid, username) {
  17.     ignoredUsers[uid] = {
  18.         'username': username,
  19.         'ignored': Date.now()
  20.     };
  21.     window.localStorage.setItem("ignoredUsers", JSON.stringify(ignoredUsers));
  22. }
  23.  
  24. function unignoreUser(uid) {
  25.     delete ignoredUsers[uid];
  26.     window.localStorage.setItem("ignoredUsers", JSON.stringify(ignoredUsers));
  27. }
  28.  
  29.  
  30.  
  31. //
  32.  
  33. function setIgnoreLink() {
  34.     if (!window.location.search.match("action=profile;u=")) {return false; }
  35.  
  36.     var infolinks, anchor, uid;
  37.     infolinks = document.getElementById("infolinks");
  38.     anchor = document.getElementById("ignorelink");
  39.     uid = window.location.search.replace(new RegExp(".+;u=(\\d+)"), "$1");
  40.  
  41.  
  42.     if (anchor) {
  43.         anchor.childNodes[0].remove();
  44.     } else {
  45.         anchor = document.createElement("a");
  46.         anchor.setAttribute("href", "#ignorelink");
  47.         anchor.setAttribute("id", "ignorelink");
  48.  
  49.         anchor.addEventListener("click", function () {
  50.             var cuid, username;
  51.             cuid = window.location.search.replace(new RegExp(".+;u=(\\d+)"), "$1");
  52.             username = document.getElementsByClassName("username")[0].textContent.trim();
  53.  
  54.  
  55.             if (ignoredUsers[cuid]) {
  56.                 unignoreUser(cuid);
  57.             } else {
  58.                 ignoreUser(cuid, username);
  59.             }
  60.  
  61.             setIgnoreLink();
  62.             return false;
  63.         });
  64.  
  65.         infolinks.appendChild(document.createElement("br"));
  66.         infolinks.appendChild(anchor);
  67.     }
  68.  
  69.  
  70.     if (ignoredUsers[uid]) {
  71.         anchor.appendChild(document.createTextNode("Unignore User"));
  72.     } else {
  73.         anchor.appendChild(document.createTextNode("Ignore User"));
  74.     }
  75.  
  76. }
  77.  
  78. //
  79.  
  80. function hideThreads() {
  81.     if (!window.location.href.match("board")) {return false; }
  82.  
  83.     var subjects, subject, uid, i;
  84.     subjects = document.getElementsByClassName('subject');
  85.  
  86.     for (i in subjects) {
  87.         subject = subjects[i];
  88.  
  89.         if (subject.getElementsByTagName) {
  90.             uid = subject.getElementsByTagName("p")[0].getElementsByTagName("a")[0].href.replace(new RegExp(".+u=(\\d+)"), "$1");
  91.  
  92.             if (ignoredUsers[uid]) {
  93.                 subject.parentNode.style.opacity = opacity;
  94.                 subject.getElementsByTagName("span")[0].style.display = "none";;
  95.                 subject.parentNode.getElementsByClassName("stats")[0].textContent = "";
  96.                 subject.parentNode.getElementsByClassName("lastpost")[0].textContent = "";
  97.             }
  98.         }
  99.     }
  100. }
  101.  
  102. function hidePosts() {
  103.     if (!window.location.href.match("topic")) {return false; }
  104.  
  105.     var posts, post, uid, i;
  106.     posts = document.getElementsByClassName('post_wrapper');
  107.  
  108.     for (i in posts) {
  109.         post = posts[i];
  110.  
  111.         if (post.getElementsByTagName) {
  112.             uid = post.getElementsByClassName("poster")[0].getElementsByTagName("h4")[0].getElementsByTagName("a")[0].href.replace(new RegExp(".+u=(\\d+)"), "$1");
  113.  
  114.             if (ignoredUsers[uid]) {
  115.                 post.parentNode.style.opacity = opacity;
  116.                 post.getElementsByClassName("avatar")[0].style.display = "none";;
  117.                 post.getElementsByClassName("post")[0].style.display = "none";;
  118.                 post.getElementsByClassName("keyinfo")[0].style.display = "none";;
  119.                 post.getElementsByClassName("reset")[0].style.display = "none";;
  120.                 post.getElementsByClassName("moderatorbar")[0].style.display = "none";;
  121.                 post.getElementsByClassName("quote_button")[0].style.display = "none";;
  122.             }
  123.         }
  124.     }
  125. }
  126.  
  127.  
  128. function hideQuotes() {
  129.     if (!window.location.href.match("topic")) {return false; }
  130.  
  131.     var quoteheaders, qh, usernames, qusername, i;
  132.     quoteheaders = document.getElementsByClassName('quoteheader');
  133.  
  134.     usernames = [];
  135.     for (i in ignoredUsers) {usernames.push(ignoredUsers[i].username); }
  136.  
  137.     for (i in quoteheaders) {
  138.         qh = quoteheaders[i];
  139.         qusername = qh.textContent.replace(new RegExp("Quote from: (.+?) on .+"), "$1").trim();
  140.  
  141.         if (usernames.indexOf(qusername) > -1) {
  142.             qh.nextSibling.textContent = "";
  143.             qh.nextSibling.style.opacity = opacity;
  144.             qh.style.opacity = opacity;
  145.         }
  146.     }
  147. }
  148.  
  149. function showIgnoredUsers() {
  150.     for(var user in ignoredUsers) {
  151.         console.log(ignoredUsers[user]["username"])
  152.     }
  153. }
  154.  
  155.  
  156. setIgnoreLink();
  157. hidePosts();
  158. hideThreads();
  159. hideQuotes();
  160. showIgnoredUsers();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement