Remove Ads and Block Popups on mkvcinemas

Removes ads, prevents popups, and blocks unwanted redirects on mkvcinemas

  1. // ==UserScript==
  2. // @name Remove Ads and Block Popups on mkvcinemas
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Removes ads, prevents popups, and blocks unwanted redirects on mkvcinemas
  6. // @author Hasan-Abbas
  7. // @match https://mkvcinemas.*/**
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14. // A function to remove an element if it exists
  15. function removeElement(selector) {
  16. const elements = document.querySelectorAll(selector);
  17. elements.forEach(el => el.remove());
  18. }
  19.  
  20. // Common ad-related selectors (you can expand this list based on observation)
  21. const adSelectors = [
  22. '#ad', // Common ID for ads
  23. '.ads', // Common class for ads
  24. '.ad-banner', // Specific ad banners
  25. '.advertisement', // Another common class
  26. '.popup', // Popups
  27. '.video-ad', // Video ads
  28. '.banner', // Banner ads
  29. 'iframe[src*="ads"]', // Iframes often contain ads
  30. '[id*="ad"]', // IDs that contain 'ad'
  31. '[class*="ad"]', // Classes that contain 'ad'
  32. '[style*="display: none"]', // Some hidden ad elements
  33. '.cookie-popup', // Cookie consent popups (can be ad related)
  34. ];
  35.  
  36. // Run remove for each selector
  37. adSelectors.forEach(selector => removeElement(selector));
  38.  
  39. // Block unwanted popups (opening new tabs or windows)
  40. const originalWindowOpen = window.open;
  41. window.open = function (url, name, specs) {
  42. // Prevent window.open from opening new tabs/windows (can be refined further if necessary)
  43. console.log("Blocked popup attempt:", url);
  44. return null;
  45. };
  46.  
  47. // Disable links that lead to external downloads or app redirects
  48. const links = document.querySelectorAll('a[href*="telegram"], a[href*="download"]');
  49. links.forEach(link => {
  50. link.addEventListener('click', (e) => {
  51. e.preventDefault();
  52. console.log('Blocked redirect to', link.href);
  53. });
  54. });
  55.  
  56. // Handle redirects by listening for location change or hijacked URLs
  57. const originalLocation = window.location.href;
  58. setInterval(() => {
  59. if (window.location.href !== originalLocation) {
  60. window.location.href = originalLocation; // Redirect back to original page
  61. }
  62. }, 1000);
  63.  
  64. // You might want to listen for dynamic content loading (like more ads appearing via JS)
  65. // If necessary, use MutationObserver to catch these dynamically loaded elements
  66. const observer = new MutationObserver(() => {
  67. adSelectors.forEach(selector => removeElement(selector));
  68. });
  69.  
  70. observer.observe(document.body, { childList: true, subtree: true });
  71.  
  72. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址