#!name=YouTube Enhance #!desc=Remove YouTube ads, enable background playback/PiP, and force highest quality. Maasea-derived code: Apache-2.0. #!arguments=block_upload:true,block_shorts:false,auto_hd:true,block_games:true #!arguments-desc=block_upload: hide Uploads; block_shorts: hide Shorts; auto_hd: force highest available quality. block_games: hide YouTube Playables. #!requirement=SYSTEM = 'iOS' [Script] youtube.enhance.ad-break = type=http-request,pattern=^https:\/\/youtubei\.googleapis\.com\/youtubei\/v1\/player\/ad_break(?:\?.*)?$,script-path=https://raw.githubusercontent.com/gholts/surge/main/scripts/youtube/request.js youtube.enhance.response = type=http-response,pattern=^https:\/\/youtubei\.googleapis\.com\/youtubei\/v1\/(?:browse|next|player|search|reel\/reel_watch_sequence|guide|account\/get_setting|get_watch|log_event|config)(?:\?.*)?$,requires-body=1,max-size=-1,binary-body-mode=1,script-path=https://raw.githubusercontent.com/gholts/surge/main/scripts/youtube/response.js,argument="{"blockUpload":{{{block_upload}}},"blockShorts":{{{block_shorts}}},"blockGames":{{{block_games}}}}" youtube.enhance.ump = type=http-response,pattern=^https?:\/\/[\w-]+\.googlevideo\.com\/initplayback(?:\?.*)?$,requires-body=1,max-size=-1,binary-body-mode=1,script-path=https://raw.githubusercontent.com/gholts/surge/main/scripts/youtube/response.js,argument="{"blockGames":{{{block_games}}}}" youtube.enhance.init = type=http-request,pattern=^https?:\/\/[\w-]+\.googlevideo\.com\/initplayback(?:\?.*)?$,requires-body=1,max-size=-1,binary-body-mode=1,script-path=https://raw.githubusercontent.com/gholts/surge/main/scripts/youtube/request.js youtube.enhance.auto-hd = type=http-request,pattern=^https?:\/\/[\w-]+\.googlevideo\.com\/videoplayback,requires-body=1,max-size=-1,binary-body-mode=1,script-path=https://raw.githubusercontent.com/gholts/surge/main/scripts/youtube/request.js,argument="{"autoHd":{{{auto_hd}}}}" youtube.enhance.log-event = type=http-request,pattern=^https:\/\/youtubei\.googleapis\.com\/youtubei\/v1\/log_event,requires-body=1,max-size=-1,binary-body-mode=1,script-path=https://raw.githubusercontent.com/gholts/surge/main/scripts/youtube/request.js [URL Rewrite] ^https:\/\/www\.youtube\.com\/(pagead|pcs)\/ - reject ^https:\/\/s\.youtube\.com\/api\/stats\/ads - reject [MITM] hostname = %APPEND% *.googlevideo.com, youtubei.googleapis.com, *.youtube.com