// ==UserScript== // @id what-toggle-formats // @name What.CD: Toggle Format Visibility // @namespace hateradio))) // @author hateradio // @version 2.8 // @description Hide formats with your discretion. // @include http*://*what.cd/torrents.php* // @include http*://*what.cd/artist.php?id=* // @include http*://*what.cd/bookmarks.php* // @include http*://*what.cd/collages.php* // @match *://*.what.cd/torrents.php* // @match *://*.what.cd/artist.php?id=* // @match *://*.what.cd/bookmarks.php* // @match *://*.what.cd/collages.php?* // @updated 24 SEP 2011 // @since 28 OCT 2010 // @downloadURL none // ==/UserScript== // S T O R A G E HANDLE var strg = { init:function(){ this.on = this.work(); }, work:function(){ try { return 'localStorage' in window && window['localStorage'] !== null; } catch(e) { return false; } }, read:function(key){ return this.on ? JSON.parse(window.localStorage.getItem(key)) : false; }, save:function(key,dat){ return this.on ? !window.localStorage.setItem(key, JSON.stringify(dat)) : false; }, wipe:function(key){ return this.on ? !window.localStorage.removeItem(key) : false; } }; strg.init(); var hide = { loc:document.querySelector('.sidebar') || document.querySelector('.linkbox'), anc:(document.getElementById('discog_table') || document.querySelector('.torrent_table')).querySelectorAll('a[href^="torrents.php?id="],a[onclick]'), str:document.querySelectorAll('.edition_info > strong'), typ:['CD','Vinyl','WEB','SACD','DVD','DAT','Cassette','Blu-ray','Soundboard'], cod:['FLAC','Ogg','AAC','AC3','DTS','MP3'], enc:['192','APS','V2','V1','256','APX','V0','320','/ Lossless','24bit Lossless'], lch:['Scene','Freeleech','Neutral Leech','Reported','Bad'], hid:strg.read('togglesettings2') || [], div:document.createElement('div'), init:function(){ var tog = this, s = document.createElement('style'), top = document.getElementsByTagName('head')[0], css = '.hider-f { text-decoration: line-through } #format-hide { text-align: center; margin: 3px 0px }'; s.type = 'text/css'; s.textContent = css; top.appendChild(s); // run! this.bond = function(m,b){ var c = function(e){ if(b !== true && e){e = e.currentTarget;} m.call(tog,e); }; return c; }; this.location(); this.generate(); this.toggle(this.hid); this.toggle(this.hid,true); this.mark(); }, location:function(){ this.div.id = 'format-hide'; this.div.className = 'box box_artists'; this.loc.parentNode.insertBefore(this.div,this.loc); }, slink:function(t){ var S = document.createElement('span'); S.data = t; S.textContent = t.replace(/(?:\/|\\)/,''); S.id = 'togformatvis_'+S.textContent.replace(/(?:\s)/,''); S.style.cursor = 'pointer'; S.addEventListener('click',this.bond(this.change), false); S.setAttribute('onmousedown','return false;'); this.div.appendChild(S); this.div.appendChild(document.createTextNode(' ')); }, proc:function(a,b){ var x = -1, y = a.length; while(++x 0 ? '(?:'+a.join('|')+')\\b' : false, x = -1, y = !b ? this.anc : this.str, z = y.length; if(r){ strg.save('togglesettings2',this.hid); r = new RegExp(r,'i'); while(++x