/CVox/res/raw/slashdot.js

http://eyes-free.googlecode.com/ · JavaScript · 52 lines · 37 code · 8 blank · 7 comment · 8 complexity · fbe59234ba97b30ecda4660c3c9635cd MD5 · raw file

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