TwitchAdSolutions icon indicating copy to clipboard operation
TwitchAdSolutions copied to clipboard

No longer working on twitch

Open TitanF1 opened this issue 1 year ago • 2 comments

No longer functions

TitanF1 avatar Oct 24 '24 17:10 TitanF1

No longer working for me on twitch either.

pluscheck avatar Oct 25 '24 01:10 pluscheck

No longer working for me either

hubertskeltrix avatar Oct 25 '24 02:10 hubertskeltrix

No longer working for me either sadly

Silliel avatar Oct 29 '24 18:10 Silliel

Same here, no longer works for at least a month...

Waldemard avatar Oct 30 '24 19:10 Waldemard

Are you guys on Google Chrome? If you could comment what browser, platform, and script you are using that would be helpful to pixeltris.

If using uBlock Origin, could be linked to the extension being disabled/removed by Chrome for not supporting MV3. Could also be uBo not loading the script #200 , userscript is recommended. Try to migrate over to the userscript versions and see if that helps. If you want to try to diagnose, you can follow the steps here. You should see those messages in your browser console if the script has loaded properly regardless of how you install the scripts.

Am still seeing the userscript versions of vaft and video-swap-new working on my end on two different systems.

stevenya97 avatar Oct 30 '24 19:10 stevenya97

@stevenya97 yes. google chrome using userscript via tampermonkey. I am not using uBlock Origin

pluscheck avatar Oct 30 '24 19:10 pluscheck

@pluscheck Gotcha, userscript has been smooth for me and I just loaded up a stream to test. Make sure to have video-swap-new OR vaft enabled, not both at the same time. Please try these steps from another thread. You should see messages pertaining to ads being detected in the console. If not, the script did not load and a conflict with another script/solution exists on your end sadly(i.e. AdGuard Extra, TTV Pro, a VPN).

stevenya97 avatar Oct 30 '24 19:10 stevenya97

@stevenya97 I use ublock in chrome and i try permanent link and update and i still get ads, what can i do

drocologue avatar Nov 01 '24 23:11 drocologue

@drocologue not sure if this will help you but I am using TwitchAdSolutions (video-swap-new) in Google Chrome and noted in the developer console I was getting the following:

Multiple twitch adblockers installed. Skipping Worker hook (video-swap-new)'

For what ever reason the script was detecting a conflict and not running. No other ad blockers or scripts were active so it should not have been occuring. I have since edited the userscript to isTwitchWorker = false to isTwitchWorker = true.

// if (newWorker.toString() !== window.Worker.toString()) { // console.log('Multiple twitch adblockers installed. Skipping Worker hook (video-swap-new)'); // isTwitchWorker = true; // }

JJDeakins1 avatar Nov 02 '24 20:11 JJDeakins1

@JJDeakins1 Do you perhaps use Adguard Extra or another adblocking script from the README? "Skipping worker hook" means it detects another script and lets that one take priority over video-swap-new. Both running same time could cause playback and buffering issues. If you have a clean install with no other extensions and userscripts that is indeed strange. Brave Browser also has their own internal scriptlet for Twitch ads that could interfere but you did mention being on Chrome

stevenya97 avatar Nov 02 '24 23:11 stevenya97

No other ad blockers or scripts were active so it should not have been occuring

@JJDeakins1 could you log and compare newWorker.toString() / window.Worker.toString() to see why that code is skipping the hook?

pixeltris avatar Nov 03 '24 04:11 pixeltris

@pixeltris I have uBlock Origin installed but disabled on Twitch and no other userscripts are active so not sure why a conflict is being produced.

Attached below is the output in the console as well as the code added to the userscript to produce the console.log when loaded on Twitch.

Console Log Output

Multiple twitch adblockers installed. Not skipping worker, forcing start

userscript.html?name=TwitchAdSolutions-video-swap-new.user.js&id=6b4984b2-3757-44a6-862e-67edf2bcd254:44

Current newWorker: class Worker extends oldWorker {
            constructor(twitchBlobUrl, options) {
                console.log('Current newWorker:', newWorker.toString());
                console.log('Current window.Worker:', window.Worker.toString());
                var isTwitchWorker = false;
                try {
                    isTwitchWorker = new URL(twitchBlobUrl).origin.endsWith('.twitch.tv');
                } catch {}
                if (newWorker.toString() !== window.Worker.toString()) {
                    console.log('Multiple twitch adblockers installed. Not skipping worker, forcing start');
                    isTwitchWorker = true;
                }
                if (!isTwitchWorker) {
                    super(twitchBlobUrl, options);
                    return;
                }
                var newBlobStr = `
                    ${processM3U8.toString()}
                    ${hookWorkerFetch.toString()}
                    ${declareOptions.toString()}
                    ${getAccessToken.toString()}
                    ${gqlRequest.toString()}
                    ${makeGraphQlPacket.toString()}
                    ${tryNotifyAdsWatchedM3U8.toString()}
                    ${parseAttributes.toString()}
                    ${onFoundAd.toString()}
                    ${getWasmWorkerUrl.toString()}
                    var workerUrl = getWasmWorkerUrl('${twitchBlobUrl.replaceAll("'", "%27")}');
                    if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) {
                        declareOptions(self);
                        self.addEventListener('message', function(e) {
                            if (e.data.key == 'UboUpdateDeviceId') {
                                gql_device_id = e.data.value;
                            } else if (e.data.key == 'UpdateClientIntegrityHeader') {
                                ClientIntegrityHeader = e.data.value;
                            } else if (e.data.key == 'UpdateAuthorizationHeader') {
                                AuthorizationHeader = e.data.value;
                            }
                        });
                        hookWorkerFetch();
                        importScripts(workerUrl);
                    }
                `
                super(URL.createObjectURL(new Blob([newBlobStr])), options);
                twitchWorkers.push(this);
                this.onmessage = function(e) {
                    // NOTE: Removed adDiv caching as '.video-player' can change between streams?
                    if (e.data.key == 'UboShowAdBanner') {
                        var adDiv = getAdDiv();
                        if (adDiv != null) {
                            adDiv.P.textContent = 'Blocking' + (e.data.isMidroll ? ' midroll' : '') + ' ads';
                            if (OPT_SHOW_AD_BANNER) {
                                adDiv.style.display = 'block';
                            }
                        }
                    } else if (e.data.key == 'UboHideAdBanner') {
                        var adDiv = getAdDiv();
                        if (adDiv != null) {
                            adDiv.style.display = 'none';
                        }
                    } else if (e.data.key == 'UboChannelNameM3U8Changed') {
                        //console.log('M3U8 channel name changed to ' + e.data.value);
                    } else if (e.data.key == 'UboReloadPlayer') {
                        reloadTwitchPlayer();
                    } else if (e.data.key == 'UboPauseResumePlayer') {
                        reloadTwitchPlayer(false, true);
                    } else if (e.data.key == 'UboSeekPlayer') {
                        reloadTwitchPlayer(true);
                    }
                }
                function getAdDiv() {
                    var playerRootDiv = document.querySelector('.video-player');
                    var adDiv = null;
                    if (playerRootDiv != null) {
                        adDiv = playerRootDiv.querySelector('.ubo-overlay');
                        if (adDiv == null) {
                            adDiv = document.createElement('div');
                            adDiv.className = 'ubo-overlay';
                            adDiv.innerHTML = '<div class="player-ad-notice" style="color: white; background-color: rgba(0, 0, 0, 0.8); position: absolute; top: 0px; left: 0px; padding: 5px;"><p></p></div>';
                            adDiv.style.display = 'none';
                            adDiv.P = adDiv.querySelector('p');
                            playerRootDiv.appendChild(adDiv);
                        }
                    }
                    return adDiv;
                }
            }
        }
Current window.Worker: class e extends Worker{onMessageFromSandbox(){this.addEventListener("message",e=>{if(e.data&&S(e.data)&&!e4(e.data)){let{type:t="",data:r}=e.data;switch(t){case"tt_pixel_init":case"tt_pixel_event":e6.emit(t,r)}}})}constructor(e,t){window.sessionStorage.setItem("tt_helper_installed","1"),super(e,t),this.onMessageFromSandbox()}}
image

JJDeakins1 avatar Nov 03 '24 10:11 JJDeakins1

Should be fixed by https://github.com/pixeltris/TwitchAdSolutions/commit/722f5b96241ef1d92998b87f941690e47e475379. I changed it to check the hierarchy for twitch specific worker hooks.

@younesaassila you might want to do a similar hierarchy check in https://github.com/younesaassila/ttv-lol-pro/blob/aaf19619136ed778e558c2751e1c8b2a22b00560/src/page/page.ts#L54-L59, though if you copy the isWorkerDoubleHooked function without any changes to where you currently have your check ads would slip through in the following setup:

  1. vaft injects / hooks the worker
  2. 0 or more external scripts hook the worker
  3. ttv-lol-pro hooks the worker In this case vaft and ttv-lol-pro will check the hierarchy and no adblocking solution will be applied. This is because ttv-lol-pro always hooks the worker even if something already has hooked it. To mitigate that it'd probably make sense to check the hierarchy before hooking (but it'd still make sense to check inside the hook itself too). For example: https://github.com/pixeltris/TwitchAdSolutions/blob/722f5b96241ef1d92998b87f941690e47e475379/video-swap-new/video-swap-new.user.js#L681-L686

pixeltris avatar Nov 03 '24 18:11 pixeltris

Should be fixed by https://github.com/pixeltris/TwitchAdSolutions/commit/722f5b96241ef1d92998b87f941690e47e475379. I changed it to check the hierarchy for twitch specific worker hooks.

@younesaassila you might want to do a similar hierarchy check in https://github.com/younesaassila/ttv-lol-pro/blob/aaf19619136ed778e558c2751e1c8b2a22b00560/src/page/page.ts#L54-L59, though if you copy the isWorkerDoubleHooked function without any changes to where you currently have your check ads would slip through in the following setup:

  1. vaft injects / hooks the worker

  2. 0 or more external scripts hook the worker

  3. ttv-lol-pro hooks the worker

In this case vaft and ttv-lol-pro will check the hierarchy and no adblocking solution will be applied. This is because ttv-lol-pro always hooks the worker even if something already has hooked it. To mitigate that it'd probably make sense to check the hierarchy before hooking (but it'd still make sense to check inside the hook itself too). For example:

https://github.com/pixeltris/TwitchAdSolutions/blob/722f5b96241ef1d92998b87f941690e47e475379/video-swap-new/video-swap-new.user.js#L681-L686

This bug only occurs if there is at least one external script hooking the worker in addition to Vaft and TTV LOL PRO, or have I misunderstood something?

younesaassila avatar Nov 03 '24 18:11 younesaassila

But yeah it makes sense to check hierarchy in case of multiple scripts being used. Will definitely look into it. Thank you

younesaassila avatar Nov 03 '24 18:11 younesaassila

This bug only occurs if there is at least one external script hooking the worker in addition to Vaft and TTV LOL PRO, or have I misunderstood something?

That's correct, so in the case of this current issue (#294) your code isn't impacted as you check the worker for stuff like "twitch":

1. ttv-lol-pro
2. external script that hooks Worker

But you would get an infinite loading screen in this scenario:

1. ttv-lol-pro
2. some twitch solution / vaft fork which doesn't have any worker checks (i.e. Stream Cleaner)
3. external script that hooks Worker

pixeltris avatar Nov 03 '24 18:11 pixeltris

Try using Brave Browser with the chrome extension, it still should work !

prxshetty avatar Nov 07 '24 03:11 prxshetty

I am still having issues with this working properly on twitch. However, it's ONLY with vaft .js link. if I change to video-swap-new and use the lower resolution swap solution instead of vaft, it works perfectly. As soon as I switch back to any of the links for vaft, ads come through as if there's no block in place.

z28power avatar Nov 07 '24 18:11 z28power

@z28power check the console log for hookWorkerFetch which signifies that the script is being applied.

If it logs either of the following then the script is disabling itself due to conflicting twitch solutions:

  • Twitch Worker is already hooked. Skipping (vaft)
  • Multiple twitch adblockers installed. Skipping Worker hook (vaft)

If that is the case add a console.log statement here:

https://github.com/pixeltris/TwitchAdSolutions/blob/aa5dff2cb54aa2a3e68304387050f01a1af08b32/vaft/vaft.user.js#L47-L49

Such that the code changes to this:

if (workerString.includes(identifier) && workerString !== ourWorkerString) {
    console.log(workerString);
    return true;
}

Refresh the page to check the logged output. Validate that the logged output isn't some external twitch solution. If it is some external twitch solution then remove that external solution and try again. If the logged output is something unrelated to twitch then paste the logged output here and I can take a look at it.

pixeltris avatar Nov 09 '24 20:11 pixeltris