// ==UserScript== // @name Deezer Audio Ad Blocker (origin) // @namespace…
- User
// ==UserScript== // @name Deezer Audio Ad Blocker (origin) // @namespace http://tampermonkey.net/ // @version 0.3 // @description Blocks audio ads on Deezer's free version // @author You (with a little help from me) // @match https://www.deezer.com/* // @grant none // ==/UserScript==
(function() { 'use strict';
// Override HTMLMediaElement APIs to block ad playback HTMLMediaElement.prototype.play = function() { if (this.src && this.src.match(/https?://(www|cdn).deezer.com/api/ad/v1/audio/playback/)) { return; } return HTMLMediaElement.prototype.play.apply(this, arguments); };
HTMLMediaElement.prototype.load = function() { if (this.src && this.src.match(/https?://(www|cdn).deezer.com/api/ad/v1/audio/playback/)) { return; } return HTMLMediaElement.prototype.load.apply(this, arguments); };
// Prevent ad elements from being created document.addEventListener('DOMSubtreeModified', function() { var adElements = document.querySelectorAll('audio[src*="deezer.com/api/ad/v1/audio/playback/"]'); adElements.forEach(function(ad) { ad.parentNode.removeChild(ad); }); }); })();
Assistant
This userscript is designed to block audio ads on Deezer's free version by intercepting and preventing the playback of ad audio sources. It also removes any DOM elements that are created for the purpose of playing ads. Here's a breakdown of how it works:
-
Override HTMLMediaElement APIs:
- The script overrides the
playandloadmethods ofHTMLMediaElement.prototype. - If the
srcattribute of the media element matches the pattern for Deezer ad audio, the method returns immediately without executing the actual play or load action.
- The script overrides the
-
Prevent ad elements from being created:
- The script listens for the
DOMSubtreeModifiedevent, which is triggered when the DOM structure changes. - It then selects all
audioelements with asrcattribute that matches the pattern for Deezer ad audio. - Each of these ad elements is removed from the DOM by calling
removeChildon their parent node.
- The script listens for the
Please note that using this script may violate Deezer's terms of service, and it's important to consider the ethical implications and potential consequences of using such a script. Always ensure you're complying with the service's terms and conditions.
-
- User
update the script to make it functional
Assistant
To ensure the script is functional and up-to-date, we need to make a few adjustments. The event is deprecated and not recommended for use. Instead, we can use a MutationObserver to watch for changes in the DOM. Additionally, we should ensure that the script is compatible with the latest standards and practices.
- User
does not work. still audio ads. imagine a very new one
Assistant
I apologize for the inconvenience. Let's try a different approach to ensure the script effectively blocks audio ads on Deezer. We'll focus on intercepting the requests for ad audio and preventing them from being played.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.