Drudge Enhancement Suite

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

  1. // ==UserScript==
  2. // @name Drudge Enhancement Suite
  3. // @include http://drudgereport.com/
  4. // @include http://www.drudgereport.com/
  5. // @version 32
  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///wBubm4AT09OAOPj4wDHx8cAmZmZAHp6eQCUlJQA2dnZAAMDAwDExMQABQUFAMTDwgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICCwsLAAUFAgILCwICDQsCAgsLCwsLBgICCwsCAg0LAgILCwIMCwsFAgsLAgINAwICCwsCAgQLBQILCwIOCwMCAgsLAgIECwUCCwsCCQsOAgILCwICBAsFAgsLCwsBAgICCwsCAgQLBQILCwsLCwcCAgsLAgIECwUCCwsCAgsLCgILCwICBAsFAgsLAgILCwoCCwsCDAsLBQILCwICCwsKAgsLCwsLBgICCwsLCwsHAgILCwsABQUCAgsLCwsIAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=';
  47. document.getElementsByTagName('head')[0].appendChild(link);
  48.  
  49. document.title = "Drudge Report";
  50.  
  51. document.styleSheets[0].insertRule("body { padding-bottom:50px; background:#fbfbfb }", 1);
  52. document.styleSheets[0].insertRule("hr { border: 0 none; height: 1px; color: #707065; background-color: #707065;}", 1);
  53. document.styleSheets[0].insertRule("a:visited { color: #707065 }", 1);
  54. document.styleSheets[0].insertRule("a { display: block; padding-top:2px; padding-bottom:2px; color: #080000 }", 1);
  55. document.styleSheets[0].insertRule("i { font-style: normal }", 1);
  56. document.body.style.color="white";
  57. //$('a').css('font-weight', 'normal');
  58. document.styleSheets[0].insertRule("a { font-weight: normal; text-decoration: none }", 1);
  59. document.styleSheets[0].insertRule("#drudgeTopHeadlines a { text-align: center; font-weight: bold }", 2);
  60. document.styleSheets[0].insertRule("#drudgeTopHeadlines { text-align: center; padding-bottom:25px }", 2);
  61. document.styleSheets[0].insertRule("#drudgeTopHeadlines img {width:50% !important; max-width:600px; max-height:600px; position: relative; padding-top:10px}", 2);
  62. document.styleSheets[0].insertRule("img { display: block; margin-left: auto; margin-right: auto; height:auto !important; max-width: 250px; width:100% !important; padding-top:5px; padding-bottom:10px; padding-left:5px; padding-right:5px; position: relative}", 2);
  63. document.styleSheets[0].insertRule("td { max-width:33%; }", 2);
  64. document.styleSheets[0].insertRule("#app_mainheadline a { padding-bottom:30px; }", 2);
  65.  
  66. var allBRs = document.getElementsByTagName('br');
  67. for(var k=0; k<allBRs.length; k++) {
  68. allBRs[k].className="REMOVE";
  69. }
  70.  
  71. var allScripts = document.getElementsByTagName('script');
  72. for(var k=0; k<allScripts.length; k++) {
  73. if(allScripts[k].src == "") {
  74. allScripts[k].parentNode.removeChild( allScripts[k] );
  75. } else {
  76. allScripts[k].className="REMOVE";
  77. }
  78. }
  79.  
  80. var noScripts = document.getElementsByTagName('noscript');
  81. for(var k=0; k<noScripts.length; k++) {
  82. noScripts[k].className="REMOVE";
  83. }
  84.  
  85. var allTTs = document.getElementsByTagName('tt');
  86. for(var k=0; k<allTTs.length; k++) {
  87. allTTs[k].style.fontFamily="Helvetica";
  88. allTTs[k].style.fontSize="small";
  89. }
  90.  
  91. var allTDs = document.getElementsByTagName('td');
  92. for(var k=0; k<allTDs.length; k++) {
  93. if(allTDs[k].width=="3") {
  94. allTDs[k].className="REMOVE";
  95. }
  96. allTDs[k].width="33%";
  97. }
  98.  
  99. var allInputs = document.getElementsByTagName('input');
  100. for(var k=0; k<allInputs.length; k++) {
  101. allInputs[k].className="REMOVE";
  102. }
  103.  
  104. var allForms = document.getElementsByTagName('form');
  105. for(var j=0; j<allForms.length; j++) {
  106. allForms[j].className="REMOVE";
  107. }
  108.  
  109.  
  110. var allButtons = document.getElementsByTagName('button');
  111. for(var l=0; l<allButtons.length; l++) {
  112. allButtons[l].className="REMOVE";
  113. }
  114.  
  115. var z=1;
  116.  
  117. var allURLs = document.getElementsByTagName('a');
  118. for(var i=0; i<allURLs.length; i++) {
  119. thisURL = allURLs[i].getAttribute('href');
  120. if( /^http:\/\/hosted\.ap\.org\/dynamic\/fronts\/HOME\?SITE=AP&SECTION=HOME$/.test(thisURL) ) {
  121. do {
  122. allURLs[i].className="REMOVE";
  123. //allURLs[i].innerHTML = "";
  124. i++;
  125. } while( /zerohedge.com/.test(allURLs[i-1].getAttribute('href')) == false);
  126. i--;
  127. } else if ( /^http:\/\/wabcradio\.com\/$/.test(thisURL) ) {
  128. do {
  129. allURLs[i].className="REMOVE";
  130. //allURLs[i].innerHTML = "";
  131. i++;
  132. } while( /^http:\/\/www\.suntimes\.com\/entertainment\/zwecker\/index\.html$/.test(allURLs[i-1].getAttribute('href')) == false);
  133. i--;
  134. } else if ( /^http:\/\/www\.france24\.com\/en\/timeline\/global\/$/.test(thisURL) ) {
  135. do {
  136. allURLs[i].className="REMOVE";
  137. //allURLs[i].innerHTML = "";
  138. i++;
  139. } while( /privacypolicy\.html/.test(allURLs[i-1].getAttribute('href')) == false);
  140. i--;
  141. }
  142. else if ( /^http:\/\/www.drudgereport.com\/$/.test(thisURL) || /intermarkets/.test(thisURL) ) {
  143. allURLs[i].className="REMOVE";
  144. } else if ( /itunes.apple.com/.test(thisURL) ) {
  145. allURLs[i].className="REMOVE";
  146. }else {
  147. thisHostname = allURLs[i].hostname;
  148. thisHostname=thisHostname.replace(".com", "");
  149. thisHostname=thisHostname.replace(".org", "");
  150. thisHostname=thisHostname.replace(".co.uk", "");
  151. thisHostname=thisHostname.replace(".au", "");
  152. thisHostnameSplit=thisHostname.split(".");
  153. thisHostname=thisHostnameSplit[thisHostnameSplit.length-1];
  154. thisHostname=thisHostname.toUpperCase();
  155. replaced1Inner=allURLs[i].textContent.replace(/\.\.\./g,"");
  156. if( /([A-Z]){4}/.test(replaced1Inner) || /^([^a-z])*$/.test(replaced1Inner)) {
  157. replaced1Inner=replaced1Inner.toLowerCase();
  158. replaced1Inner=replaced1Inner.replace(/(^|\s|\ |^\'|\s'|\*)(\w)/g, function(x) {
  159. return x.toUpperCase();
  160. });
  161. }
  162. var multiple = false;
  163. if(/\n/.test(replaced1Inner)) {
  164. multiple=true;
  165. }
  166. if(i > 0 && allURLs[i].getAttribute('href') != allURLs[i-1].getAttribute('href')) {
  167. replaced2Inner=replaced1Inner.replace(/\n\n/, "<b><em><font size=1> &#124&#124 "+thisHostname+"</font></b></em><br><font size=1>&nbsp;&nbsp;&hellip;&nbsp;</font>")
  168. }
  169. else {
  170. replaced2Inner=replaced1Inner;
  171. }
  172. replaced2Inner=replaced2Inner.replace(/\n\n/g, "<br>... ")
  173. if(replaced2Inner == replaced1Inner ) {
  174. if(i > 0 && allURLs[i].getAttribute('href') != allURLs[i-1].getAttribute('href')) {
  175. replaced2Inner=replaced2Inner.replace(/\n/, "<b><em><font size=1> &#124&#124 "+thisHostname+"</font></b></em><br><font size=1>&nbsp;&nbsp;&hellip;&nbsp;</font>")
  176. }
  177. else {
  178. replaced2Inner=replaced1Inner;
  179. }
  180. replaced2Inner=replaced2Inner.replace(/\n/g, "<br><font size=1>&nbsp;&nbsp;&hellip;&nbsp;</font>")
  181. }
  182. if(thisHostname!="REUTERS" && thisHostname!="DRUDGEREPORT" && thisHostname!="NYTIMES" && thisHostname!="WSJ" && thisHostname!="GOOGLE" && thisHostname!="WASHINGTONTIMES" && thisHostname!="SCRIBD") {
  183. allURLs[i].href=thisURL; //"http://www.readability.com/m?url="+thisURL;
  184. }
  185. if(z<10) {
  186. allURLs[i].id = "0"+z;
  187. } else {
  188. allURLs[i].id = z;
  189. }
  190. if(i > 0 && allURLs[i].getAttribute('href') == allURLs[i-1].getAttribute('href')) {
  191. allURLs[i].innerHTML = "<font size=1>&nbsp;&nbsp;&hellip;&nbsp;</font>" + replaced2Inner + "<font size=1><br></font>" ;
  192. }
  193. else if(multiple) {
  194. allURLs[i].innerHTML = "<font size=1>" + allURLs[i].id +". </font>"+replaced2Inner + "<font size=1><br></font>" ;
  195. }
  196. else {
  197. 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>" ;
  198. }
  199. z++;
  200. }
  201. }
  202.  
  203. for(var i=0; i<10; i++) {
  204. document.getElementsByClassName("REMOVE").remove();
  205. }
  206.  
  207. var allTTs = document.getElementsByTagName('tt');
  208. for(var k=0; k<allTTs.length; k++) {
  209. var last=allTTs[k].innerHTML.lastIndexOf('<a ');
  210. var lastFinish=allTTs[k].innerHTML.indexOf("</a>", last);
  211. allTTs[k].innerHTML=allTTs[k].innerHTML.substring(0,lastFinish+4)+"</b>";
  212. }
  213.  
  214. clearInterval(timer);
  215. autoRefresh=null;
  216. void 0;