TheFantasticLoki

Remove J-Ads Scripts and Links V2 now blocking Juicyads.*

Jun 23rd, 2023
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Remove JADS Scripts and Links
  3. // @namespace loki-scripts
  4. // @version 2
  5. // @description Removes any script or link containing "jads" or "juicyads" in the URL from webpages
  6. // @match *://*/*
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12.  
  13. // Define a regular expression to match URLs containing "jads" or "juicyads"
  14. const blockedRegExp = /jads|juicyads/i;
  15.  
  16. // Define an array of URLs to block
  17. const blockedUrls = [
  18. 'xapi.juicyads.com',
  19. 'juicyads.rocks'
  20. // Add any other URLs you want to block here
  21. ];
  22.  
  23. // Find all <script> and <link> elements on the page
  24. const scripts = document.querySelectorAll('script,link');
  25.  
  26. // Loop through each element
  27. for (let i = 0; i < scripts.length; i++) {
  28. const script = scripts[i];
  29.  
  30. // Check if the element's href or src attribute contains the blockedRegExp
  31. if (blockedRegExp.test(script.href) || blockedRegExp.test(script.src)) {
  32.  
  33. // Loop through the blockedUrls array
  34. for (let j = 0; j < blockedUrls.length; j++) {
  35.  
  36. // Check if the element's href or src attribute contains a blocked URL
  37. if (script.href.includes(blockedUrls[j]) || script.src.includes(blockedUrls[j])) {
  38.  
  39. // If it does, remove the element from the page
  40. script.parentNode.removeChild(script);
  41. break;
  42. }
  43. }
  44. }
  45. }
  46. })();
  47.  
Advertisement
Add Comment
Please, Sign In to add comment