Skip to content

Instantly share code, notes, and snippets.

@ArnaudLigny
Last active November 12, 2020 20:35
Show Gist options
  • Save ArnaudLigny/64d7f70c22f07a9eee490a39766dc11b to your computer and use it in GitHub Desktop.
Save ArnaudLigny/64d7f70c22f07a9eee490a39766dc11b to your computer and use it in GitHub Desktop.
How To Block Twitch Ads
# https://ttv-ublock.vercel.app/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);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment