Enhanced Corrupt Dailymotion Ads

Corrupts ads on Dailymotion by blocking playback

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Enhanced Corrupt Dailymotion Ads
// @namespace    https://pastebin.com/tiAedV19
// @version      2.0
// @description  Corrupts ads on Dailymotion by blocking playback
// @match        https://www.dailymotion.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const adSources = [
        'ad',
        'advertisement',
        'doubleclick',
        'adserver',
        'ads',
        'tracking',
        'spotxchange',
        'krxd.net',
        'brighttag',
        'vdopia',
        'dailymotion.com/ads',
        'googleads',
        'adtech',
        'serving-sys',
        'adsrvr',
        'adroll',
        'adnxs',
        'adform',
        'rubiconproject',
        'appnexus',
        'zencoder',
        'floodlight',
        'criteo',
        'indexexchange',
        'openx',
        'smaato',
        'yieldmo',
        'adcolony',
        'moatads',
        'brightroll',
        'liveintent',
        'taboola',
        'outbrain',
        'revcontent',
        'adsbygoogle',
        'sovrn',
        'sonobi',
        'mopub',
        'audiencenetwork',
        'flashtalking',
        'triplelift',
        'fetchback',
        'adbeast',
        'adpushup',
        'improvely',
        'videonow',
        'extreme-reach',
        'adview',
        'adserverpub',
        'adsnative',
        'yieldbot',
        'moat',
        'improvedigital',
        'cysend',
        'media.net',
        'adswizz',
        'spotx',
        'gumgum',
        'kontera',
        'nativeads',
        'adf.ly',
        'shorte.st',
        'adfender',
        'fanboost',
        'nativo',
        'adlib',
        'mediacom',
        'admatic',
        'videoplaza',
        'mocean',
        'adconion',
        'justpremium',
        'openadstream',
        'admeld',
        'smaato',
        'adswapper',
        'mediaalpha',
        'brainly',
        'adblade',
        'tapad',
        'adparlor',
        'adknowledge',
        'tremorvideo',
        'radiumone',
        'uzymedia',
        'adgear',
        'cpxinteractive',
        'whiteshark',
        'adcontrol',
        'adspring',
        'maxymiser',
        'booster',
        'customaudience',
        'geniuslink',
        'intango',
        'igum',
        'leadbolt',
        'adaction',
        'buysellads',
        'clicksor',
        'zebraads',
        'advertise.com',
        'ezanga',
        'videojug',
        'avocarrot',
        'fyber',
        'yandex',
        'adlibitum',
        'popads',
        'popunder',
        'atdmt',
        'adpolicy',
        'acxiom',
        'mopub',
        'criteo',
        'dynamicyield',
        'adpiler',
        'arbitraryads',
        'adtrader',
        'adhero',
        'digitalenvoy',
        'cocoon',
        'adshuffler',
        'backflip',
        'advangelists',
        'interclick',
        'adman',
        'adscape',
        'adattic',
        'adsidian',
        'adperium',
        'retargeting',
        'bidswitch',
        'adteca',
        'whaleads',
        'buyat',
        'adshuffle',
        'inmobi',
        'interscroller',
        'proxio',
        'adcloud',
        'adserving',
        'adunity',
        'pof.com',
        'roboads',
        'in-ads',
        'hypeaudience',
        'yahooads',
        'vungle',
        'chartboost',
        'unityads',
        'applovin',
        'adnetwork',
        'innoads',
        'adpure',
        'adsoft',
        'redefiningads',
        'mmedia',
        'weborama',
        'newads',
        'adspring',
        'deputyads',
        'dcollab',
        'dsp',
        'quantcast',
        'adfuse',
        'epom',
        'adext',
        'rsi',
        'thetradedesk',
        'buzzcity',
        'criteo',
        'districtm',
        'plista',
        'veeboo',
        'adopt',
        'admitad',
        'kargo',
        'squeezy',
        'clearcode',
        'adupay',
        'spinme',
        'yuga',
        'inetwork',
        'adwallet',
        'myads',
        'adfunnel',
        'unitedads',
        'adwarrior',
        'metaad',
        'intelligentads',
        'mediacore',
        'driftrock',
        '360ads',
        'adclick',
        'splashad',
        'adbrokers',
        'reachlocal',
        'adiq',
        'adzero',
        'adspresso',
        'netseer',
        'btrll',
        'conviva',
        'bitrate',
        'adtraction',
        'adstring',
        'adviewmedia',
        'interceptd',
        'avora',
        'mindspark',
        'aolads',
        'adnow',
        'adverty',
        'adcloudmedia',
        'adoption',
        'inspireads',
        'broadstreetads',
        'exponential',
        'crossmedia',
        'triplelift',
        'lotame',
        'nexage',
        'clickable',
        'dove',
        'inviqa',
        'adspark',
        'addefend',
        'fastclick',
        'adnet',
        'adexchanger',
        'metricads',
        'simpleads',
        'upliftads',
        'advolcano',
        'spotx',
        'twitch',
        'preroll',
    ];

    const isAdSource = (src) => {
        return adSources.some(ad => src.includes(ad));
    };

    const corruptAds = () => {
        const originalPlay = HTMLMediaElement.prototype.play;

        HTMLMediaElement.prototype.play = function() {
            if (isAdSource(this.src)) {
                return Promise.reject(new Error('Ad playback failed due to connection issues.'));
            }
            return originalPlay.call(this);
        };
    };

    const suppressConsoleWarnings = () => {
        const originalError = console.error;
        console.error = function(...args) {
            if (args[0] && typeof args[0] === 'string' && args[0].includes('Reading cookie in cross-site context')) {
                return;
            }
            originalError.apply(console, args);
        };
    };

    window.addEventListener('load', () => {
        suppressConsoleWarnings();
        corruptAds();

        const observer = new MutationObserver(() => {
            corruptAds();
        });
        observer.observe(document.body, { childList: true, subtree: true });
    });
})();