Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Pricewatch strikethrough
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author You
- // @match https://tweakers.net/categorie/*
- // @grant GM_registerMenuCommand
- // @grant GM_unregisterMenuCommand
- // @grant GM_setValue
- // @grant GM_getValue
- // ==/UserScript==
- (function() {
- 'use strict';
- function handler() {
- var li = document.getElementsByClassName('facetCount');
- for(var i=0; i<li.length; i++){
- if(mode){
- li[i].parentNode.parentNode.style.display = li[i].innerText == '0' ? 'none' : '';
- }
- else {
- if(li[i].parentNode.getElementsByClassName('facetLabel').length > 0){
- li[i].parentNode.getElementsByClassName('facetLabel')[0].style.textDecoration = li[i].innerText == '0' ? 'line-through red' : '';
- }
- }
- }
- }
- function menu() {
- mode = !mode;
- GM_setValue('mode', mode);
- GM_unregisterMenuCommand(id);
- id = GM_registerMenuCommand(modes[+mode], menu);
- }
- function checkHash(cb) {
- if(hash == location.hash) {
- return;
- }
- hash = location.hash;
- cb();
- }
- var mode = GM_getValue('mode', false);
- var modes = ['Remove', 'Strikethrough'];
- var hash = location.hash;
- var id = GM_registerMenuCommand(modes[+mode], menu);
- //window.addEventListenter('hashchange', handler, false);
- window.setInterval(checkHash, 500, handler);
- })();
Add Comment
Please, Sign In to add comment