Last active
February 22, 2023 10:05
-
-
Save seandlg/4a8f8cd2ab316c5a3636ce7155d3a254 to your computer and use it in GitHub Desktop.
yachtworld Ad Remover
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name yachtworld.de Ad Remover | |
// @namespace Violentmonkey Scripts | |
// @match https://www.yachtworld.de/boote-kaufen/* | |
// @grant none | |
// @version 1.2 | |
// @author seandlg | |
// @description 22/02/2023, 10:55:38 | |
// @downloadURL https://gist.githubusercontent.com/seandlg/4a8f8cd2ab316c5a3636ce7155d3a254/raw | |
// ==/UserScript== | |
// Select the node that will be observed for changes | |
const listingsContainer = document.querySelector('.listings-container'); | |
// Create a new observer instance | |
const observer = new MutationObserver(function(mutationsList, observer) { | |
// Iterate through each mutation | |
for(const mutation of mutationsList) { | |
// Check if the mutation is a childList change to the listings container | |
if (mutation.type === 'childList' && mutation.target === listingsContainer) { | |
console.log('Listings container has changed! Removing ads..'); | |
try { | |
Array.from(document.querySelectorAll(".listing-card.enhanced")).forEach(elem => elem.remove()) | |
} catch { | |
console.log("Cannot remove ad..") | |
} | |
} | |
} | |
}); | |
// Start observing the listings container for changes | |
observer.observe(listingsContainer, { childList: true }); | |
// Initial ad deletion | |
try { | |
Array.from(document.querySelectorAll(".listing-card.enhanced")).forEach(elem => elem.remove()) | |
} catch { | |
console.log("Cannot remove ad..") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment