BetterFark

I miss FarkAnalReverteresque and smiths

当前为 2016-03-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name BetterFark
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description I miss FarkAnalReverteresque and smiths
  6. // @author LesserEvil
  7. // @match http://www.fark.com/*
  8. // @match http://fark.com/*
  9. // @match https://www.fark.com/*
  10. // @match https://fark.com/*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. 'use strict';
  15.  
  16. function scrollIntoView(eleID) {
  17. var e = document.getElementById(eleID);
  18. if (!!e && e.scrollIntoView) {
  19. e.scrollIntoView();
  20. }
  21. }
  22.  
  23. function appendElementToBody(elem)
  24. {
  25. document.getElementsByTagName('body')[0].appendChild(elem);
  26. }
  27. function injectStyles(rule) {
  28. var elem = document.createElement("DIV");
  29. elem.innerHTML = '<style>' + rule + '</style>';
  30. appendElementToBody(elem);
  31. }
  32.  
  33. function doRemoveBubbles()
  34. {
  35. var commentIcons = document.getElementsByClassName("icon_comment");
  36. var i, bubbleCount=0;
  37. for( i in commentIcons )
  38. {
  39. if ( typeof(commentIcons[i]) == "object" )
  40. {
  41. if ( commentIcons[i].className != null )
  42. {
  43. bubbleCount++;
  44. commentIcons[i].className = "better_comment";
  45. }
  46. }
  47. }
  48. console.log("scrubbing "+bubbleCount+" bubbles away");
  49. }
  50.  
  51. function displayFarkNew()
  52. {
  53. scrollIntoView("new");
  54. }
  55.  
  56. function doBetterFark()
  57. {
  58. console.log("Making Fark a better place for you and me");
  59. var newsContainer = document.querySelectorAll('div#newsContainer')[0];
  60. var mainContainer = document.querySelectorAll('div#container')[0];
  61. if ( newsContainer !== null )
  62. {
  63. newsContainer.style.width = '100%';
  64. }
  65. else
  66. {
  67. console.log("Unable to find div.newsContainer");
  68. }
  69. if ( mainContainer !== null )
  70. {
  71. mainContainer.style.width = '100%';
  72. }
  73. else
  74. {
  75. console.log("Unable to find div.container");
  76. }
  77. injectStyles('a.icon_comment { border-width: 0px; }');
  78. injectStyles('a.better_comment { font-size: 120%; }');
  79. doRemoveBubbles();
  80. doRemoveBubbles();
  81. doRemoveBubbles();
  82. doRemoveBubbles();
  83. setTimeout(displayFarkNew(),100);
  84. setTimeout(doRemoveBubbles(), 100);
  85. setTimeout(doRemoveBubbles(), 200);
  86. setTimeout(doRemoveBubbles(), 3000);
  87.  
  88. }
  89.  
  90. setTimeout(doBetterFark(),100);