Guest User

Pricewatch strikethrough

a guest
May 1st, 2019
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Pricewatch strikethrough
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://tweakers.net/categorie/*
  8. // @grant GM_registerMenuCommand
  9. // @grant GM_unregisterMenuCommand
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // ==/UserScript==
  13.  
  14. (function() {
  15.  
  16. 'use strict';
  17. function handler() {
  18. var li = document.getElementsByClassName('facetCount');
  19. for(var i=0; i<li.length; i++){
  20. if(mode){
  21. li[i].parentNode.parentNode.style.display = li[i].innerText == '0' ? 'none' : '';
  22. }
  23. else {
  24. if(li[i].parentNode.getElementsByClassName('facetLabel').length > 0){
  25. li[i].parentNode.getElementsByClassName('facetLabel')[0].style.textDecoration = li[i].innerText == '0' ? 'line-through red' : '';
  26. }
  27. }
  28. }
  29. }
  30.  
  31. function menu() {
  32. mode = !mode;
  33. GM_setValue('mode', mode);
  34. GM_unregisterMenuCommand(id);
  35. id = GM_registerMenuCommand(modes[+mode], menu);
  36. }
  37.  
  38. function checkHash(cb) {
  39. if(hash == location.hash) {
  40. return;
  41. }
  42. hash = location.hash;
  43. cb();
  44. }
  45.  
  46. var mode = GM_getValue('mode', false);
  47. var modes = ['Remove', 'Strikethrough'];
  48. var hash = location.hash;
  49. var id = GM_registerMenuCommand(modes[+mode], menu);
  50.  
  51. //window.addEventListenter('hashchange', handler, false);
  52. window.setInterval(checkHash, 500, handler);
  53.  
  54. })();
Add Comment
Please, Sign In to add comment