I attempted to utilize the script below to eliminate all audio from a specific website:
// ==UserScript==
// @name addicto
// @namespace nms
// @include http://*
// @include https://*
// @version 1
// @grant none
// ==/UserScript==
addEventListener('DOMContentLoaded', ()=>{
let sites = ['mako.co.il'];
let href = window.location.href;
for (let i = 0; i < sites.length; i++) {
if (href.includes(sites[i])) {
Array.prototype.slice.call(document.querySelectorAll('audio')).forEach((audio)=>{
audio.muted = true;
});
}
}
// If href includes the value of the iteration on the "sites" array, do stuff.
});
This script did not successfully remove the audio, leading me to believe that using a mutation observer to handle randomly incoming audio
tags and DOM manipulation might be a more effective approach.
Could someone provide a simple example of how to write a mutation observer for this purpose? I am new to mutation observers, and I believe a basic example like this would greatly help me and others facing a similar issue to better understand the logic and context of the code. Thank you in advance to anyone willing to provide guidance.