Drudge Enhancement Suite

Drudge Enhancement Suite. Main focus is on readability. I recommend using this in conjunction with an adblock extension like uBlock.

目前为 2015-04-22 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Drudge Enhancement Suite
  3. // @include http://drudgereport.com/
  4. // @include http://www.drudgereport.com/
  5. // @version 4
  6. // @grant none
  7. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  8. // @description:en Drudge Enhancement Suite. Main focus is on readability. I recommend using this in conjunction with an adblock extension like uBlock.
  9. //
  10. // @namespace https://greasyfork.org/users/10724
  11. // @description Drudge Enhancement Suite. Main focus is on readability. I recommend using this in conjunction with an adblock extension like uBlock.
  12. // ==/UserScript==
  13.  
  14. var firstNum=-1;
  15. var secondNum=-1;
  16.  
  17. Element.prototype.remove = function() {
  18. this.parentElement.removeChild(this);
  19. }
  20. NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
  21. for(var i = 0, len = this.length; i < len; i++) {
  22. if(this[i] && this[i].parentElement) {
  23. this[i].parentElement.removeChild(this[i]);
  24. }
  25. }
  26. }
  27.  
  28. document.addEventListener('keydown', function(event) {
  29. var num = event.keyCode-48;
  30. if(num >= 0 && num<=9) {
  31. if(firstNum==-1) {
  32. firstNum=num;
  33. } else if(secondNum==-1) {
  34. secondNum=num;
  35. fullNum=firstNum.toString()+secondNum.toString();
  36. document.getElementById(fullNum).click();
  37. firstNum=-1;
  38. secondNum=-1;;
  39. }
  40. }
  41. });
  42.  
  43. var link = document.createElement('link');
  44. link.type = 'image/x-icon';
  45. link.rel = 'shortcut icon';
  46. link.href = 'data:image/x-icon;base64,AAABAAEAEBAAAAAAAABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAACKiYgAjIyMAP///wBubm4AT09OAOPj4wDHx8cAmZmZAHp6eQCUlJQA2dnZAAMDAwDExMQABQUFAMTDwgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICCwsLAAUFAgILCwICDQsCAgsLCwsLBgICCwsCAg0LAgILCwIMCwsFAgsLAgINAwICCwsCAgQLBQILCwIOCwMCAgsLAgIECwUCCwsCCQsOAgILCwICBAsFAgsLCwsBAgICCwsCAgQLBQILCwsLCwcCAgsLAgIECwUCCwsCAgsLCgILCwICBAsFAgsLAgILCwoCCwsCDAsLBQILCwICCwsKAgsLCwsLBgICCwsLCwsHAgILCwsABQUCAgsLCwsIAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=';
  47. document.getElementsByTagName('head')[0].appendChild(link);
  48.  
  49. document.title = "Drudge Report";
  50.  
  51. document.styleSheets[0].insertRule("a:visited { color: #A3A3A3 }", 1);
  52. document.styleSheets[0].insertRule("a { display: block; padding-top:2px; padding-bottom:2px }", 1);
  53. document.styleSheets[0].insertRule("i { font-style: normal }", 1);
  54. document.body.style.color="white";
  55. //$('a').css('font-weight', 'normal');
  56. document.styleSheets[0].insertRule("a { font-weight: normal; text-decoration: none }", 1);
  57. document.styleSheets[0].insertRule("#drudgeTopHeadlines a { text-align: center; font-weight: bold }", 2);
  58. document.styleSheets[0].insertRule("#drudgeTopHeadlines { text-align: center; padding-bottom:15px }", 2);
  59. document.styleSheets[0].insertRule("img {display: block; margin-left: auto; margin-right: auto; height:auto; width:auto; max-width:400px; max-height:400px; padding-top:5px; padding-bottom:5px; padding-left:5px; padding-right:5px}", 2);
  60.  
  61. var allBRs = document.getElementsByTagName('br');
  62. for(var k=0; k<allBRs.length; k++) {
  63. allBRs[k].className="REMOVE";
  64. }
  65.  
  66. var allScripts = document.getElementsByTagName('script');
  67. for(var k=0; k<allScripts.length; k++) {
  68. allScripts[k].className="REMOVE";
  69. }
  70.  
  71. var noScripts = document.getElementsByTagName('noscript');
  72. for(var k=0; k<noScripts.length; k++) {
  73. noScripts[k].className="REMOVE";
  74. }
  75.  
  76. var allTTs = document.getElementsByTagName('tt');
  77. for(var k=0; k<allTTs.length; k++) {
  78. allTTs[k].style.fontFamily="Helvetica";
  79. allTTs[k].style.fontSize="small";
  80. }
  81.  
  82. var allTDs = document.getElementsByTagName('td');
  83. for(var k=0; k<allTDs.length; k++) {
  84. if(allTDs[k].width=="3") {
  85. allTDs[k].className="REMOVE";
  86. }
  87. }
  88.  
  89. var allInputs = document.getElementsByTagName('input');
  90. for(var k=0; k<allInputs.length; k++) {
  91. allInputs[k].className="REMOVE";
  92. }
  93.  
  94. var allForms = document.getElementsByTagName('form');
  95. for(var j=0; j<allForms.length; j++) {
  96. allForms[j].className="REMOVE";
  97. }
  98.  
  99.  
  100. var allButtons = document.getElementsByTagName('button');
  101. for(var l=0; l<allButtons.length; l++) {
  102. allButtons[l].className="REMOVE";
  103. }
  104.  
  105. var z=1;
  106.  
  107. var allURLs = document.getElementsByTagName('a');
  108. for(var i=0; i<allURLs.length; i++) {
  109. thisURL = allURLs[i].getAttribute('href');
  110. if( /^http:\/\/news\.myway\.com\/index\/id\/world%7Cap.html$/.test(thisURL) ) {
  111. do {
  112. allURLs[i].className="REMOVE";
  113. //allURLs[i].innerHTML = "";
  114. i++;
  115. } while( /x17online.com/.test(allURLs[i-1].getAttribute('href')) == false);
  116. i--;
  117. } else if ( /^http:\/\/wabcradio\.com\/$/.test(thisURL) ) {
  118. do {
  119. allURLs[i].className="REMOVE";
  120. //allURLs[i].innerHTML = "";
  121. i++;
  122. } while( /^http:\/\/www\.suntimes\.com\/entertainment\/zwecker\/index\.html$/.test(allURLs[i-1].getAttribute('href')) == false);
  123. i--;
  124. } else if ( /^http:\/\/www\.france24\.com\/en\/timeline\/global\/$/.test(thisURL) ) {
  125. do {
  126. allURLs[i].className="REMOVE";
  127. //allURLs[i].innerHTML = "";
  128. i++;
  129. } while( /privacypolicy\.html/.test(allURLs[i-1].getAttribute('href')) == false);
  130. i--;
  131. }
  132. else if ( /^http:\/\/www.drudgereport.com\/$/.test(thisURL) || /intermarkets/.test(thisURL) ) {
  133. allURLs[i].className="REMOVE";
  134. } else {
  135. allURLs[i].target="_blank";
  136. thisHostname = allURLs[i].hostname;
  137. thisHostname=thisHostname.replace(".com", "");
  138. thisHostname=thisHostname.replace(".org", "");
  139. thisHostname=thisHostname.replace(".co.uk", "");
  140. thisHostnameSplit=thisHostname.split(".");
  141. thisHostname=thisHostnameSplit[thisHostnameSplit.length-1];
  142. thisHostname=thisHostname.toUpperCase();
  143. replaced1Inner=allURLs[i].textContent.replace(/\.\.\./g,"");
  144. if( /([A-Z]){5}/.test(replaced1Inner)) {
  145. replaced1Inner=replaced1Inner.toLowerCase();
  146. replaced1Inner=replaced1Inner.replace(/(^|\s|\ ')(\w)/g, function(x) {
  147. return x.toUpperCase();
  148. });
  149. }
  150. var multiple = false;
  151. if(/\n/.test(replaced1Inner)) {
  152. multiple=true;
  153. }
  154. if(i > 0 && allURLs[i].getAttribute('href') != allURLs[i-1].getAttribute('href')) {
  155. replaced2Inner=replaced1Inner.replace(/\n\n/, "<b><em><font size=1> &#124&#124 "+thisHostname+"</font></b></em><br>... ")
  156. }
  157. else {
  158. replaced2Inner=replaced1Inner;
  159. }
  160. replaced2Inner=replaced2Inner.replace(/\n\n/g, "<br>... ")
  161. if(replaced2Inner == replaced1Inner ) {
  162. if(i > 0 && allURLs[i].getAttribute('href') != allURLs[i-1].getAttribute('href')) {
  163. replaced2Inner=replaced2Inner.replace(/\n/, "<b><em><font size=1> &#124&#124 "+thisHostname+"</font></b></em><br>... ")
  164. }
  165. else {
  166. replaced2Inner=replaced1Inner;
  167. }
  168. replaced2Inner=replaced2Inner.replace(/\n/g, "<br>... ")
  169. }
  170. if(thisHostname!="NYTIMES") {
  171. allURLs[i].href="http://www.readability.com/m?url="+thisURL;
  172. }
  173. if(z<10) {
  174. allURLs[i].id = "0"+z;
  175. } else {
  176. allURLs[i].id = z;
  177. }
  178. if(i > 0 && allURLs[i].getAttribute('href') == allURLs[i-1].getAttribute('href')) {
  179. allURLs[i].innerHTML = "... " + replaced2Inner + "<font size=1><br></font>" ;
  180. }
  181. else if(multiple) {
  182. allURLs[i].innerHTML = "<font size=1>" + allURLs[i].id +"</font>"+". "+replaced2Inner + "<font size=1><br></font>" ;
  183. }
  184. else {
  185. allURLs[i].innerHTML = "<font size=1>" + allURLs[i].id +". </font>"+replaced2Inner + "<b><em><font size=1> &#124&#124 "+thisHostname+"</b></em></font>" + "<font size=1><br></font>" ;
  186. }
  187. z++;
  188. }
  189. }
  190.  
  191. for(var i=0; i<10; i++) {
  192. document.getElementsByClassName("REMOVE").remove();
  193. }
  194.  
  195. var allTTs = document.getElementsByTagName('tt');
  196. for(var k=0; k<allTTs.length; k++) {
  197. var last=allTTs[k].innerHTML.lastIndexOf('<a ');
  198. var lastFinish=allTTs[k].innerHTML.indexOf("</a>", last);
  199. allTTs[k].innerHTML=allTTs[k].innerHTML.substring(0,lastFinish+4)+"</b>";
  200. }