Skip to content

Instantly share code, notes, and snippets.

@odensc

odensc/ads.js Secret

Last active May 21, 2024 16:13
Show Gist options
  • Save odensc/764900d841cbdd8aa400796001e189f1 to your computer and use it in GitHub Desktop.
Save odensc/764900d841cbdd8aa400796001e189f1 to your computer and use it in GitHub Desktop.
uBlock Twitch ad fix (v3) - Alternative link with no caching; https://ttv-ublock.vercel.app/twitch-videoad.js
/// twitch-videoad.js
const origFetch = window.fetch;
window.fetch = (url, init, ...args) => {
if (typeof url === "string") {
if (url.includes("/access_token")) {
// url = url.replace("player_type=site", "player_type=site");
} else if (
url.includes("/gql") &&
init &&
typeof init.body === "string" &&
init.body.includes("PlaybackAccessToken")
) {
// const newBody = JSON.parse(init.body);
// newBody.variables.playerType = "site";
// init.body = JSON.stringify(newBody);
}
}
return origFetch(url, init, ...args);
};
@odensc
Copy link
Author

odensc commented Nov 6, 2020

@PureFallen thanks for that note, I just completely commented it out for now. Also, they locked the frontpage player_type so it only blocks ads on streams that are actually featured on the frontpage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment