Kawiesh

Starnieuws AdBlock

Nov 8th, 2020 (edited)
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Final: https://gist.github.com/kawiesh/128aa6b330dfb777dd50c2ce6f9df9aa
  2.  
  3. // ==UserScript==
  4. // @name        Starnieuws - AdBlock
  5. // @namespace   AdBlocker for Starnieuws
  6. // @match       *://*.starnieuws.com/*
  7. // @grant       none
  8. // @version     2.0
  9. // @author      K.D.
  10. // @description Removes ads on Starnieuws!
  11. // ==/UserScript==
  12.  
  13. //SELECTORS FOR ADS
  14. let a= [];
  15. a[0]= 'span[style*=BEBEBE]';
  16. a[1]= '#sidebar';
  17. a[2]= '.adbox_top';
  18. a[3]= '#adbox_content';
  19. a[4]= 'br+.overig_nieuws';
  20. a[5]= 'img[src*=advertentie]';
  21. a[6]= 'img[id*=ad_]';
  22.  
  23. //FUNCTION TO HIDE THE ADS
  24. function hideAds(x){
  25. let b= document.querySelectorAll(x);
  26. for (let i=0; i<b.length; i++){
  27. b[i].parentNode.removeChild(b[i]);
  28. }
  29. }
  30.  
  31. //CALLING THE FUNCTION
  32. for (let i=0; i<a.length; i++){
  33. hideAds(a[i]);
  34. }
  35.  
  36. //REMOVING BACKGROUND & DIVIDER
  37. let c= document.querySelector('#topstory'),
  38. d= document.querySelectorAll('div[id=overig_nieuws]');
  39.  
  40. if (c) {
  41. c.style.backgroundImage='none';
  42. c.style.backgroundColor='white';
  43. }
  44.  
  45. if(d) d[0].style.display='none';
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54. ........older.........
  55.  
  56. // ==UserScript==
  57. // @name        Starnieuws - Remove Ads
  58. // @namespace   K.D.
  59. // @match       *://*.starnieuws.com/*
  60. // @grant       none
  61. // @version     1.0
  62. // @author      K.D.
  63. // @description Remove advertisements on Starnieuws.com
  64. // ==/UserScript==
  65.  
  66. (function() {
  67.   'use strict';
  68.  
  69. var blockList = [
  70. "m.starnieuws.com##td:nth-of-type(2)",
  71. "m.starnieuws.com##.headlines_content > div",
  72. "m.starnieuws.com##.content > div:nth-of-type(3) > div:nth-of-type(5)",
  73. "m.starnieuws.com##div:nth-of-type(6)",
  74. "www.starnieuws.com###sidebar",
  75. "www.starnieuws.com##.headlines_content > div",
  76. "www.starnieuws.com###topstory > div:nth-of-type(1)",
  77. "www.starnieuws.com###topstory > div:nth-of-type(3)",
  78. "www.starnieuws.com###content_text > div:nth-of-type(3)",
  79. "www.starnieuws.com###content_text > div:nth-of-type(4)",
  80. "www.starnieuws.com##div#overig_nieuws:nth-of-type(4)"
  81. ];
  82.  
  83.   var windowHostname = window.location.hostname;
  84.  
  85.   for (var i = 0; i < blockList.length; i++) {
  86.     var entryParts = blockList[i].split('##');
  87.    
  88.     if (windowHostname === entryParts[0]) {
  89.       var matchedElements = document.querySelectorAll(entryParts[1]);
  90.      
  91.       for (var j = 0; j < matchedElements.length; j++) {
  92.         var matchedElem = matchedElements[j];
  93.  
  94.         matchedElem.parentNode.removeChild(matchedElem);
  95.       }
  96.     }
  97.   }
  98. })();
  99.  
  100. ......
  101.  
  102. GM_addStyle(`
  103. #content2{
  104. background-image:none;
  105. background-color:white;
  106. }
  107. span, div[style*='clear:both'], #adbox_content, .adbox_content,
  108. #sidebar,img[src*='advertentie']{
  109. display:none!important;
  110. }
  111. `);
  112.  
  113. let a= location.href;
  114. if (a.includes('/nieuwsitem/')) {
  115. let b= document.querySelector('i'),
  116.     bhr= document.createElement('hr');
  117.     b.parentNode.insertBefore(bhr,b);
  118. let c= document.querySelector('.headlines_content'),
  119.     chr= document.createElement('hr');
  120.     c.parentNode.insertBefore(chr, c);
  121.  
  122. /*let d= document.querySelectorAll('.overig_nieuws');
  123.       d.parentNode.removeChildNode(d);*/
  124. }
  125.  
  126.  
  127.  
  128. .....
  129. // ==UserScript==
  130. // @name        JavaScript AdBlox
  131. // @namespace   AdBlox JS
  132. // @match       *://*.starnieuws.com/*
  133. // @grant       GM_addStyle
  134. // @version     1.0
  135. // @author      -
  136. // @description BOOMER
  137. // ==/UserScript==
  138.  
  139. GM_addStyle(`
  140. #topstory{
  141. background-image:none;
  142. background-color:white;
  143. }`);
  144.  
  145. let a= [];
  146. a[0]= 'span[style*=BEBEBE]';
  147. a[1]= '#sidebar';
  148. a[2]= '.adbox_top';
  149. a[3]= '#adbox_content';
  150. a[4]= 'br+.overig_nieuws';
  151. a[5]= 'img[src*=advertentie]';
  152. a[6]= 'img[id*=ad_]';
  153. function hideAds(x){
  154.   let b= document.querySelectorAll(x);
  155.     for (let i=0; i<b.length; i++){
  156.      b[i].parentNode.removeChild(b[i]);
  157.     }
  158. }
  159. for (let i=0; i<a.length; i++){
  160.   hideAds(a[i]);
  161. }
  162.  
  163. let d= document.querySelectorAll('div[id=overig_nieuws]');
  164. d[0].style.display='none';
  165. .....
  166.  
  167. #content2{
  168. filter: invert(1);
  169. }
  170.    
  171. #content2 iframe,
  172. #content2 video,
  173. #content2 img:not([src*='video']){
  174. filter: invert(1);
  175. }
  176.  
  177. #content_header_section, #content2 a {
  178. color:fuchsia!important;
  179. }
  180.  
  181. #content2 img:not([src*='video']){
  182. outline: 1px solid #39FF14
  183. }
  184.  
  185. ......
  186.  
  187.  
  188.  
  189.  
  190. (function() {
  191.   'use strict';
  192.  
  193.   var blockList = [*PASTE*];
  194.  
  195.   var windowHostname = window.location.hostname;
  196.  
  197.   for (var i = 0; i < blockList.length; i++) {
  198.     var entryParts = blockList[i].split('##');
  199.    
  200.     if (windowHostname === entryParts[0]) {
  201.       var matchedElements = document.querySelectorAll(entryParts[1]);
  202.      
  203.       for (var j = 0; j < matchedElements.length; j++) {
  204.         var matchedElem = matchedElements[j];
  205.  
  206.         matchedElem.parentNode.removeChild(matchedElem);
  207.       }
  208.     }
  209.   }
  210. })();
  211.  
  212.  
  213. -------------
  214. /*
  215. Source: Zach Saucier @ Stackoverflow
  216. Link: https://stackoverflow.com/questions/44368691/how-to-conveniently-hide-elements-selected-using-an-adblocker-via-a-userscript
  217. */
Add Comment
Please, Sign In to add comment