silencer.js
// Checks for the div with the running track length
Checks for the div with the running track length
Checks for the div with the running track length
function checkElementPresent() {
    let nowPlayingElements = getNowPlayingElements();
    if (nowPlayingElements.length > 0) {
        window.clearInterval(intervalID);
        var observer = new MutationObserver(function(mutations) {
            silentBrowserIfAd();
        });
        for (let element of nowPlayingElements) {
            observer.observe(element, {
                characterData: true,
                childList: true,
                subtree: true
            });
        }
        chrome.runtime.sendMessage({action: "initialised"});
    }
}
function checkElementPresent ( ) { let nowPlayingElements = getNowPlayingElements ( ) ; if ( nowPlayingElements . length > 0 ) { window . clearInterval ( intervalID ) ; var observer = new MutationObserver ( function ( mutations ) { silentBrowserIfAd ( ) ; } ) ; for ( let element of nowPlayingElements ) { observer . observe ( element , { characterData : true , childList : true , subtree : true } ) ; } chrome . runtime . sendMessage ( { action : "initialised" } ) ; } }
Checks for the div with the running track length
Checks for the div with the running track length
/*let TrackLengthElement = getTrackLengthElement();
    // If found:
    if (!!TrackLengthElement) {
        // Stop the process o check every 1s
        window.clearInterval(intervalID);
        // adds an observer everytime the track length changes
        // (So every time  new track is played)
        var observer = new MutationObserver(function(mutations) {
            // Each change : check if ad and silence tab if so.
            silentBrowserIfAd();
        });
        // starts observer (defined above)
        observer.observe(TrackLengthElement, {
            characterData: true,
            childList: true,
            subtree: true
        });
        // Warns background that the extension has initialised correctly.
        chrome.runtime.sendMessage({action: "initialised"});
    }*/ // If found: // Stop the process o check every 1s // adds an observer everytime the track length changes // (So every time  new track is played) // Each change : check if ad and silence tab if so. // starts observer (defined above) // Warns background that the extension has initialised correctly.