/CVox/res/raw/slashdot.js
JavaScript | 52 lines | 37 code | 8 blank | 7 comment | 8 complexity | fbe59234ba97b30ecda4660c3c9635cd MD5 | raw file
1 2// ==UserScript== 3// @name Optimize Slashdot for mobile screen 4// @description Hide navigation bars on Slashdot to optimize for mobile screens 5// @author Jeffrey Sharkey 6// @include http://*slashdot.org* 7// ==/UserScript== 8 9function hideById(id) { 10 var target = document.getElementById(id); 11 if(target == null) return; 12 target.style.display = 'none'; 13} 14 15function flattenById(id) { 16 var target = document.getElementById(id); 17 if(target == null) return; 18 target.style.padding = '0px'; 19 target.style.margin = '0px'; 20} 21 22function flattenByClass(parent, tag, className) { 23 var items = parent.getElementsByTagName(tag); 24 for(i in items) { 25 var item = items[i]; 26 if(typeof item.className !== 'string') continue; 27 if(item.className.indexOf(className) != -1) { 28 item.style.padding = '0px'; 29 item.style.margin = '0px'; 30 } 31 } 32} 33 34 35hideById('links'); 36hideById('fad1'); 37hideById('fad2'); 38hideById('fad3'); 39hideById('fad6'); 40hideById('fad30'); 41hideById('fad60'); 42hideById('slashboxes'); 43 44var yuimain = document.getElementById('yui-main'); 45flattenByClass(yuimain,'div','yui-b'); 46flattenByClass(yuimain,'div','maincol'); 47flattenByClass(yuimain,'div','article usermode thumbs'); 48 49// these usually only apply when logged in 50flattenById('contents'); 51flattenById('articles'); 52flattenById('indexhead');