Skip to content

Instantly share code, notes, and snippets.

@t0rr3sp3dr0
Last active January 14, 2026 02:17
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, *.api.amazonvideo.com, *.prime-video.amazon.dev, *.prod.cloud.netflix.com, *.cdn.peacocktv.com, *.ads.twitch.tv
[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
Netflix = type=http-request,pattern=https://.+[.]prod[.]cloud[.]netflix[.]com/graphql,requires-body=0,script-path=https://gist.github.com/t0rr3sp3dr0/affec5cb71de89b7fe6226374852f40d/raw/Netflix.js,script-update-interval=300
let body = JSON.parse($response.body);
body['stream']['insertion']['points'] = [];
$done({ body: JSON.stringify(body) });
let url = $request.url;
let regExp = new RegExp('[?&]path_prefix(=([^&#]*)|&|#|$)');
let pathPrefix = decodeURIComponent(regExp.exec(url)[2]);
let body = $response.body;
let extInf = '';
let output = [];
for (let line of body.split('\n')) {
if (line.startsWith('#EXT-X-DATERANGE:')) {
continue;
}
if (line.startsWith('#EXT-X-MAP:') && !line.includes(pathPrefix)) {
continue;
}
if (line.startsWith('#EXTINF:')) {
extInf = line;
continue;
}
if (extInf !== '') {
if (!line.includes(pathPrefix)) {
extInf = '';
continue;
}
output.push(extInf);
extInf = '';
}
output.push(line);
}
$done({ body: output.join('\n') });
let headers = $request.headers;
if (!['InterstitialForLolomo', 'InterstitialsForProfileGateAndLolomo'].includes(headers['x-netflix.context.operation-name'])) {
$done();
} else {
$done({
response: {
status: 500,
},
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment