Skip to content

Instantly share code, notes, and snippets.

@Decad
Last active November 2, 2020 11:00
Show Gist options
  • Save Decad/b734ff3e0816e4db308a928e231129d3 to your computer and use it in GitHub Desktop.
Save Decad/b734ff3e0816e4db308a928e231129d3 to your computer and use it in GitHub Desktop.
Block twitch preroll
/// 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=embed");
} else if (
url.includes("/gql") &&
init &&
typeof init.body === "string" &&
init.body.includes("PlaybackAccessToken")
) {
const newBody = JSON.parse(init.body);
newBody.variables.playerType = "embed";
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