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 3
  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 allTTs = document.getElementsByTagName('tt');
  72. for(var k=0; k<allTTs.length; k++) {
  73. allTTs[k].style.fontFamily="Helvetica";
  74. allTTs[k].style.fontSize="small";
  75. }
  76.  
  77. var allTDs = document.getElementsByTagName('td');
  78. for(var k=0; k<allTDs.length; k++) {
  79. if(allTDs[k].width=="3") {
  80. allTDs[k].className="REMOVE";
  81. }
  82. }
  83.  
  84. var allInputs = document.getElementsByTagName('input');
  85. for(var k=0; k<allInputs.length; k++) {
  86. allInputs[k].className="REMOVE";
  87. }
  88.  
  89. var allForms = document.getElementsByTagName('form');
  90. for(var j=0; j<allForms.length; j++) {
  91. allForms[j].className="REMOVE";
  92. }
  93.  
  94.  
  95. var allButtons = document.getElementsByTagName('button');
  96. for(var l=0; l<allButtons.length; l++) {
  97. allButtons[l].className="REMOVE";
  98. }
  99.  
  100. var z=1;
  101.  
  102. var allURLs = document.getElementsByTagName('a');
  103. for(var i=0; i<allURLs.length; i++) {
  104. thisURL = allURLs[i].getAttribute('href');
  105. if( /^http:\/\/news\.myway\.com\/index\/id\/world%7Cap.html$/.test(thisURL) ) {
  106. do {
  107. allURLs[i].className="REMOVE";
  108. //allURLs[i].innerHTML = "";
  109. i++;
  110. } while( /x17online.com/.test(allURLs[i-1].getAttribute('href')) == false);
  111. i--;
  112. } else if ( /^http:\/\/wabcradio\.com\/$/.test(thisURL) ) {
  113. do {
  114. allURLs[i].className="REMOVE";
  115. //allURLs[i].innerHTML = "";
  116. i++;
  117. } while( /^http:\/\/www\.suntimes\.com\/entertainment\/zwecker\/index\.html$/.test(allURLs[i-1].getAttribute('href')) == false);
  118. i--;
  119. } else if ( /^http:\/\/www\.france24\.com\/en\/timeline\/global\/$/.test(thisURL) ) {
  120. do {
  121. allURLs[i].className="REMOVE";
  122. //allURLs[i].innerHTML = "";
  123. i++;
  124. } while( /privacypolicy\.html/.test(allURLs[i-1].getAttribute('href')) == false);
  125. i--;
  126. }
  127. else if ( /^http:\/\/www.drudgereport.com\/$/.test(thisURL) || /intermarkets/.test(thisURL) ) {
  128. allURLs[i].className="REMOVE";
  129. } else {
  130. allURLs[i].target="_blank";
  131. thisHostname = allURLs[i].hostname;
  132. thisHostname=thisHostname.replace(".com", "");
  133. thisHostname=thisHostname.replace(".org", "");
  134. thisHostname=thisHostname.replace(".co.uk", "");
  135. thisHostnameSplit=thisHostname.split(".");
  136. thisHostname=thisHostnameSplit[thisHostnameSplit.length-1];
  137. thisHostname=thisHostname.toUpperCase();
  138. replaced1Inner=allURLs[i].textContent.replace(/\.\.\./g,"");
  139. if( /([A-Z]){5}/.test(replaced1Inner)) {
  140. replaced1Inner=replaced1Inner.toLowerCase();
  141. replaced1Inner=replaced1Inner.replace(/(^|\s|\ ')(\w)/g, function(x) {
  142. return x.toUpperCase();
  143. });
  144. }
  145. var multiple = false;
  146. if(/\n/.test(replaced1Inner)) {
  147. multiple=true;
  148. }
  149. if(i > 0 && allURLs[i].getAttribute('href') != allURLs[i-1].getAttribute('href')) {
  150. replaced2Inner=replaced1Inner.replace(/\n\n/, "<b><em><font size=1> &#124&#124 "+thisHostname+"</font></b></em><br>... ")
  151. }
  152. else {
  153. replaced2Inner=replaced1Inner;
  154. }
  155. replaced2Inner=replaced2Inner.replace(/\n\n/g, "<br>... ")
  156. if(replaced2Inner == replaced1Inner ) {
  157. if(i > 0 && allURLs[i].getAttribute('href') != allURLs[i-1].getAttribute('href')) {
  158. replaced2Inner=replaced2Inner.replace(/\n/, "<b><em><font size=1> &#124&#124 "+thisHostname+"</font></b></em><br>... ")
  159. }
  160. else {
  161. replaced2Inner=replaced1Inner;
  162. }
  163. replaced2Inner=replaced2Inner.replace(/\n/g, "<br>... ")
  164. }
  165. if(thisHostname!="NYTIMES") {
  166. allURLs[i].href="http://www.readability.com/m?url="+thisURL;
  167. }
  168. if(z<10) {
  169. allURLs[i].id = "0"+z;
  170. } else {
  171. allURLs[i].id = z;
  172. }
  173. if(i > 0 && allURLs[i].getAttribute('href') == allURLs[i-1].getAttribute('href')) {
  174. allURLs[i].innerHTML = "... " + replaced2Inner + "<font size=1><br></font>" ;
  175. }
  176. else if(multiple) {
  177. allURLs[i].innerHTML = "<font size=1>" + allURLs[i].id +"</font>"+". "+replaced2Inner + "<font size=1><br></font>" ;
  178. }
  179. else {
  180. 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>" ;
  181. }
  182. z++;
  183. }
  184. }
  185.  
  186. for(var i=0; i<10; i++) {
  187. document.getElementsByClassName("REMOVE").remove();
  188. }
  189.  
  190. var allTTs = document.getElementsByTagName('tt');
  191. for(var k=0; k<allTTs.length; k++) {
  192. var last=allTTs[k].innerHTML.lastIndexOf("<a id");
  193. var lastFinish=allTTs[k].innerHTML.indexOf("</a>", last);
  194. allTTs[k].innerHTML=allTTs[k].innerHTML.substring(0,lastFinish+4)+"</b>";
  195. }