Last active
January 25, 2026 02:03
-
-
Save t0rr3sp3dr0/affec5cb71de89b7fe6226374852f40d to your computer and use it in GitHub Desktop.
Block Ads via NSSurge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [URL Rewrite] | |
| "https://.+[.]api[.]amazonvideo[.]com/cdp/getVideoAds[?].+" - reject | |
| "https://.+[.]prime-video[.]amazon[.]dev/getVideoAds[?].+" - reject | |
| "https://.+[.]cdn[.]peacocktv[.]com/dai/.+" - reject | |
| "https://.+[.]cdn[.]peacocktv[.]com/intmvpvod/.+[.]m3u8[?](.+&)?vam_params=.+" - reject | |
| "https://.+[.]ads[.]twitch[.]tv/.+" - reject | |
| [MITM] | |
| hostname = disney.playback.edge.bamgrid.com, dynamic-manifest.hulustream.com, www.youtube.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 | |
| Hulu = type=http-response,pattern=https://dynamic-manifest[.]hulustream[.]com/hulu/v1/vod/hls/variant/.+,requires-body=1,max-size=2097152,binary-body-mode=0,script-path=https://gist.github.com/t0rr3sp3dr0/affec5cb71de89b7fe6226374852f40d/raw/Hulu.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 | |
| YouTube@tv = type=http-response,pattern=https://www[.]youtube[.]com/tv($|[?].+),requires-body=1,max-size=2097152,binary-body-mode=0,script-path=https://gist.github.com/t0rr3sp3dr0/affec5cb71de89b7fe6226374852f40d/raw/YouTube@tv.js,script-update-interval=300 | |
| YouTube@youtubei@v1@browse = type=http-response,pattern=https://www[.]youtube[.]com/youtubei/v1/browse[?].+,requires-body=1,max-size=2097152,binary-body-mode=0,script-path=https://gist.github.com/t0rr3sp3dr0/affec5cb71de89b7fe6226374852f40d/raw/YouTube@youtubei@v1@browse.js,script-update-interval=300 | |
| YouTube@youtubei@v1@player = type=http-response,pattern=https://www[.]youtube[.]com/youtubei/v1/player[?].+,requires-body=1,max-size=2097152,binary-body-mode=0,script-path=https://gist.github.com/t0rr3sp3dr0/affec5cb71de89b7fe6226374852f40d/raw/YouTube@youtubei@v1@player.js,script-update-interval=300 | |
| YouTube@youtubei@v1@search = type=http-response,pattern=https://www[.]youtube[.]com/youtubei/v1/search[?].+,requires-body=1,max-size=2097152,binary-body-mode=0,script-path=https://gist.github.com/t0rr3sp3dr0/affec5cb71de89b7fe6226374852f40d/raw/YouTube@youtubei@v1@search.js,script-update-interval=300 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let body = JSON.parse($response.body); | |
| body['stream']['insertion']['points'] = []; | |
| $done({ body: JSON.stringify(body) }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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') }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let headers = $request.headers; | |
| if (['InterstitialForLolomo', 'InterstitialForPlayback', 'InterstitialsForProfileGateAndLolomo'].includes(headers['x-netflix.context.operation-name'])) { | |
| $done({ response: { status: 500 } }); | |
| } else { | |
| $done(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let headers = $response.headers; | |
| headers['Content-Security-Policy'] = "default-src * 'self' 'unsafe-inline' 'unsafe-eval' 'cobalt-insecure-local-network' 'cobalt-insecure-private-range' https: http: file: data: blob:"; | |
| let body = $response.body; | |
| body = body.replace('<head>', `<head> | |
| <script> | |
| const map = window.Array.prototype.map; | |
| window.Array.prototype.map = function(...args) { | |
| if (this[0]?.adPlacementRenderer || this[0]?.adSlotRenderer) { | |
| return []; | |
| } | |
| return map.apply(this, arguments); | |
| }; | |
| const isTypeSupported = window.MediaSource.isTypeSupported; | |
| window.MediaSource.isTypeSupported = function(type, ...args) { | |
| for (const [k, v] of Object.entries({ | |
| 'width': '99999', | |
| 'height': '99999', | |
| 'framerate': '9999', | |
| 'bitrate': '2000000000', | |
| 'eotf': 'catavision', | |
| 'channels': '99', | |
| 'cryptoblockformat': 'invalidformat', | |
| 'decode-to-texture': 'nope', | |
| 'codecs': 'av99.0.05M.08', | |
| 'experimental': 'invalid', | |
| 'tunnelmode': 'false', | |
| })) { | |
| if (type.endsWith('; ' + k + '=' + v)) { | |
| return false; | |
| } | |
| } | |
| if (type.includes('; codecs="vp9"') || type.includes('; codecs="vp09.00.') || type.includes('; codecs="vp09.01.')) { | |
| return true; | |
| } | |
| return isTypeSupported.apply(this, arguments); | |
| }; | |
| </script>`); | |
| $done({ headers, body }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let body = JSON.parse($response.body); | |
| const contents = body.contents?.tvBrowseRenderer?.content?.tvSurfaceContentRenderer?.content?.sectionListRenderer?.contents || body.continuationContents?.sectionListContinuation?.contents || []; | |
| for (let i = contents.length - 1; i >= 0; i--) { | |
| const content = contents[i]; | |
| if (content.adSlotRenderer || content.adPlacementRenderer || content.feedNudgeRenderer || content.promoShelfRenderer || content.statementBannerRenderer || content.shelfRenderer?.headerRenderer?.heroCarouselHeaderRenderer) { | |
| contents.splice(i, 1); | |
| } else { | |
| const items = content.shelfRenderer?.content?.horizontalListRenderer?.items || []; | |
| for (let j = items.length - 1; j >= 0; j--) { | |
| const item = items[j]; | |
| if (item.adSlotRenderer || item.adPlacementRenderer || item.feedNudgeRenderer || item.promoShelfRenderer || item.statementBannerRenderer) { | |
| items.splice(j, 1); | |
| } | |
| } | |
| } | |
| } | |
| $done({ body: JSON.stringify(body) }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let body = JSON.parse($response.body); | |
| delete body.adPlacements; | |
| $done({ body: JSON.stringify(body) }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let body = JSON.parse($response.body); | |
| const contents = body.contents?.sectionListRenderer?.contents || []; | |
| for (let i = contents.length - 1; i >= 0; i--) { | |
| const content = contents[i]; | |
| if (content.adSlotRenderer || content.adPlacementRenderer || content.feedNudgeRenderer || content.promoShelfRenderer || content.statementBannerRenderer) { | |
| contents.splice(i, 1); | |
| } else { | |
| const items = content.shelfRenderer?.content?.horizontalListRenderer?.items || []; | |
| for (let j = items.length - 1; j >= 0; j--) { | |
| const item = items[j]; | |
| if (item.adSlotRenderer || item.adPlacementRenderer || item.feedNudgeRenderer || item.promoShelfRenderer || item.statementBannerRenderer) { | |
| items.splice(j, 1); | |
| } | |
| } | |
| } | |
| } | |
| $done({ body: JSON.stringify(body) }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment