Skip to content

Instantly share code, notes, and snippets.

@t0rr3sp3dr0
Last active December 28, 2025 08:58
Show Gist options
  • Select an option

  • Save t0rr3sp3dr0/affec5cb71de89b7fe6226374852f40d to your computer and use it in GitHub Desktop.

Select an option

Save t0rr3sp3dr0/affec5cb71de89b7fe6226374852f40d to your computer and use it in GitHub Desktop.
Block Ads via NSSurge
[URL Rewrite]
"https://.+[.]ads[.]twitch[.]tv/.+" - reject
"https://.+[.]api[.]amazonvideo[.]com/cdp/getVideoAds[?].+" - reject
"https://.+[.]prime-video[.]amazon[.]dev/getVideoAds[?].+" - reject
"https://.+[.]cdn[.]peacocktv[.]com/intmvpvod/.+[.]m3u8[?](.+&)?vam_params=.+" - reject
[MITM]
hostname = disney.playback.edge.bamgrid.com, dynamic-manifest.hulustream.com, *.ads.twitch.tv, *.api.amazonvideo.com, *.prime-video.amazon.dev, *.cdn.peacocktv.com
[Script]
Disney+ = type=http-response,pattern=https://disney[.]playback[.]edge[.]bamgrid[.]com/v7/playback/.+,requires-body=1,max-size=2097152,binary-body-mode=0,script-path=https://gist.github.com/t0rr3sp3dr0/affec5cb71de89b7fe6226374852f40d/raw/Disney+.js,script-update-interval=300
let body = JSON.parse($response.body);
body['stream']['insertion']['points'] = [];
$done({ body: JSON.stringify(body) });
let body = $response.body;
let ad = false;
let startD = 0;
let offset = 0;
let lines = [];
for (let line of body.split('\n')) {
if (line.startsWith('#EXT-X-DATERANGE:')) {
const startD0 = (new Date(line.match(/,START-DATE="([^"]+)"/)[1])).getTime();
if (ad) {
offset += startD0 - startD;
}
startD = startD0;
ad = line.includes(',X-COM-HULU-CONTENT-MANIFEST-PERIOD-TYPE-2018="ad"');
if (!ad) {
const startD1 = (new Date(startD0 - offset)).toISOString();
line = line.replace(/,START-DATE="[^"]+"/, `,START-DATE="${startD1}"`);
}
}
if (!ad) {
lines.push(line);
}
}
$done({ body: lines.join('\n') });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment