Advertisement
Guest User

IEX Ignore v0.2

a guest
May 3rd, 2017
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name IEX Forum Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description If you ignore it, it'll go away!
  6. // @author You
  7. // @match https://www.iex.nl/Forum/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // vul hier de user-id's in die je wilt blokkeren (posts onzichtbaar)
  15. // het commentaar kun je gebruiken om een naam erbij te zetten
  16. var blocked = [
  17.     "123", // Jan
  18.     "1234", // Piet
  19.     "12345" // Klaas
  20. ];
  21.  
  22. // vul hier de user-id's in die je wilt negeren (posts onzichtbaar, maar zichtbaar te maken)
  23. // het commentaar kun je gebruiken om een naam erbij te zetten
  24. var ignored = [
  25.     "123", // Jan
  26.     "1234", // Piet
  27.     "12345" // Klaas
  28. ];
  29.  
  30. var showFn = function(e) {e.target.nextSibling.style.display = "block"; e.target.parentNode.removeChild(e.target);};
  31. var containsFn = function(id, list) {for (var i = 0; i < list.length; i++) {if (id == list[i]) return true;} return false;};
  32.  
  33. var posts = document.getElementsByClassName("ForumPost");
  34. for (var i = 0; i < posts.length; i++) {
  35.     var post = posts[i];
  36.     var userBox = post.getElementsByClassName("UserName")[0];
  37.     var userId = userBox.getAttribute("href").match(/Leden\/(\d+)\//)[1];
  38.     if (containsFn(userId, blocked)) {
  39.         post.style.display = "none";
  40.     } else if (containsFn(userId, ignored)) {
  41.         var content = post.getElementsByClassName("Post")[0];
  42.         content.style.display = "none";
  43.         userBox.innerText += " [ignored]";
  44.         var showBtn = document.createElement("span");
  45.         showBtn.innerText = "[show]";
  46.         showBtn.addEventListener("click", showFn);
  47.         content.parentNode.insertBefore(showBtn, content);
  48.     }
  49. }})();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement