Trendyol Sponsor Ad Remover

This script hides specific ads on Trendyol to enhance the shopping experience.

  1. // ==UserScript==
  2. // @name Trendyol Sponsor Ad Remover
  3. // @name:tr Trendyol Sponsor Reklam Gizleyici
  4. // @version 1.4
  5. // @description This script hides specific ads on Trendyol to enhance the shopping experience.
  6. // @description:tr Bu script, Trendyol'daki belirli reklamları gizleyerek alışveriş deneyimini iyileştirir.
  7. // @author Alyssa B. Morton
  8. // @match https://www.trendyol.com/*
  9. // @grant GM_addStyle
  10. // @license MIT
  11. // @icon https://cdn.dsmcdn.com/web/production/favicon.ico
  12. // @namespace https://violentmonkey.github.io/
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. const hideAds = () => {
  19. try {
  20. // Select all ad containers
  21. const adElements = document.querySelectorAll('div.p-card-wrppr.with-campaign-view');
  22.  
  23. adElements.forEach(ad => {
  24. // Check if the ad contains the specific image
  25. const img = ad.querySelector('img[src="https://cdn.dsmcdn.com//seller-ads/editor/resources/seller-selection-stamp-v16.png"]');
  26. if (img) {
  27. // Hide the specific ad container
  28. ad.style.display = 'none'; // Hide the ad
  29. }
  30. });
  31. } catch (error) {
  32. console.error('Error hiding ads:', error);
  33. }
  34. };
  35.  
  36. const debounce = (func, delay) => {
  37. let timeout;
  38. return function(...args) {
  39. clearTimeout(timeout);
  40. timeout = setTimeout(() => func.apply(this, args), delay);
  41. };
  42. };
  43.  
  44. // Wait for the page to load completely
  45. window.addEventListener('load', () => {
  46. hideAds(); // Execute the hideAds function after the page has fully loaded
  47.  
  48. // Set up a MutationObserver to watch for changes in the DOM
  49. const observer = new MutationObserver(debounce(() => {
  50. hideAds(); // Call hideAds whenever the DOM changes
  51. }, 300));
  52.  
  53. // Start observing the body for changes
  54. observer.observe(document.body, { childList: true, subtree: true });
  55. });
  56. })();