mirror of
https://github.com/AdguardTeam/AdguardFilters.git
synced 2026-08-31 12:23:36 +00:00
Update #203236 youtube.com
This commit is contained in:
@@ -741,8 +741,8 @@ www.youtube.com#%#(()=>{const e={apply:(e,t,n)=>{const o=Reflect.apply(e,t,n);tr
|
||||
www.youtube.com#%#//scriptlet('adjust-setTimeout', '[native code]', '17000', '0.001')
|
||||
www.youtube.com#%#(()=>{let t=document.location.href,e=[],n=[],o="",r=!1;const i=Array.prototype.push,a={apply:(t,o,a)=>(window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id&&a[0]&&a[0]!==window&&"number"==typeof a[0].start&&a[0].end&&"ssap"===a[0].namespace&&a[0].id&&(r||0!==a[0]?.start||n.includes(a[0].id)||(e.length=0,n.length=0,r=!0,i.call(e,a[0]),i.call(n,a[0].id)),r&&0!==a[0]?.start&&!n.includes(a[0].id)&&(i.call(e,a[0]),i.call(n,a[0].id))),Reflect.apply(t,o,a))};window.Array.prototype.push=new Proxy(window.Array.prototype.push,a),document.addEventListener("DOMContentLoaded",(function(){if(!window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id)return;const i=()=>{const t=document.querySelector("video");if(t&&e.length){const i=Math.round(t.duration),a=Math.round(e.at(-1).end/1e3),c=n.join(",");if(!1===t.loop&&o!==c&&i&&i===a){const n=e.at(-1).start/1e3;t.currentTime<n&&(t.currentTime=n,r=!1,o=c)}else if(!0===t.loop&&i&&i===a){const n=e.at(-1).start/1e3;t.currentTime<n&&(t.currentTime=n,r=!1,o=c)}}};i();new MutationObserver((()=>{t!==document.location.href&&(t=document.location.href,e.length=0,n.length=0,r=!1),i()})).observe(document,{childList:!0,subtree:!0})}))})();
|
||||
! Fix ads with a specific Google account and for case when JSON.stringify is not writable
|
||||
www.youtube.com#%#(()=>{const e="pyv",t="param",a="client_screen",n="ad_type",c="none";let r=t;const o=window.JSON.stringify,l=e=>{r=e};(()=>{try{const e=Object.getOwnPropertyDescriptor(window.JSON,"parse");return!!e&&e.writable}catch(e){return!1}})()||((()=>{const e={apply:(e,t,a)=>{try{const e=t;e?.includes('"minimumPlaybackRate":100,"maximumPlaybackRate":100')&&(t=e.replace('"minimumPlaybackRate":100,"maximumPlaybackRate":100','"minimumPlaybackRate":25,"maximumPlaybackRate":200'))}catch(e){}return Reflect.apply(e,t,a)}};window.String.prototype.replace=new Proxy(window.String.prototype.replace,e)})(),l(a));const i=e=>{(e.playbackContext||e.playerRequest)&&delete e.context?.client?.configInfo?.appInstallData},y=(r,o,l)=>{try{if(!r||!o||!l)return;if(l===t&&"CHANNEL"!==r.context?.client?.clientScreen)return r.params?.startsWith("yAEB")||(r.params=`yAEB${r.params?r.params:""}`),r.playerRequest&&!r.playerRequest.params?.startsWith("yAEB")&&(r.playerRequest.params=`yAEB${r.playerRequest.params?r.playerRequest.params:""}`),r.playbackContext&&!r.playbackContext.params?.startsWith("yAEB")&&(r.playbackContext.params=`yAEB${r.playbackContext.params?r.playbackContext.params:""}`),void i(r);if(l===e&&"CHANNEL"!==r.context?.client?.clientScreen&&!o.params?.startsWith("yAEB"))return o.adPlaybackContext={pyv:!0},void i(r);if(l===a&&"WEB"===r.context?.client?.clientName)return r.context.client.clientScreen="CHANNEL",void i(r);if(l===n)return o.adPlaybackContext={adType:"AD_TYPE_INSTREAM"},void i(r);if(l===c)return void delete o.adPlaybackContext}catch(e){}},p=["playerErrorMessageRenderer","UNPLAYABLE"],s={apply:(i,y,s)=>{if(location.href.includes("/shorts/")||location.href.includes("youtube.com/tv")||location.href.includes("youtube.com/embed/")||r===c)return Reflect.apply(i,y,s);let u;try{if(u=Reflect.apply(i,y,s),!u.responseContext&&!u.playabilityStatus)return u;const d=o(u);return p.some((e=>d.includes(e)))&&!d.includes("CONTENT_CHECK_REQUIRED")?r===t?(l(e),u):r===e?(l(a),u):r===a?(l(n),u):(l(c),u):(r===n&&u.playerConfig?.granularVariableSpeedConfig&&(u.playerConfig.granularVariableSpeedConfig.maximumPlaybackRate=200,u.playerConfig.granularVariableSpeedConfig.minimumPlaybackRate=25),u)}catch(e){}return u}};window.JSON.parse=new Proxy(window.JSON.parse,s);const u={apply:(e,t,a)=>{if(location.href.includes("/shorts/")||location.href.includes("youtube.com/tv")||location.href.includes("youtube.com/embed/"))return Reflect.apply(e,t,a);try{let n=a[0];if(n&&(n.includes('"contentPlaybackContext"')||n.includes('"adSignalsInfo"'))){const c=JSON.parse(n);if(!c.context?.client)return Reflect.apply(e,t,a);c.playbackContext&&y(c,c.playbackContext,r),c.playerRequest&&y(c,c.playerRequest.playbackContext,r),n=o(c),a[0]=n}}catch(e){}return Reflect.apply(e,t,a)}};window.TextEncoder.prototype.encode=new Proxy(window.TextEncoder.prototype.encode,u);const d={apply:(e,t,a)=>{if(location.href.includes("/shorts/")||location.href.includes("youtube.com/tv")||location.href.includes("youtube.com/embed/"))return Reflect.apply(e,t,a);try{const n=a[0];if(!n?.context?.client)return Reflect.apply(e,t,a);n.playbackContext&&void 0===n.playbackContext.adPlaybackContext&&y(n,n.playbackContext,r),n.playerRequest&&void 0===n.playerRequest.playbackContext.adPlaybackContext&&y(n,n.playerRequest.playbackContext,r),a[0]=n}catch(e){}return Reflect.apply(e,t,a)}};window.JSON.stringify=new Proxy(window.JSON.stringify,d);const b={construct:(e,t,a)=>{try{const n=t[0];let c=t[1]?.body;if(!n?.includes("youtubei")||location.href.includes("/shorts/")||location.href.includes("youtube.com/tv")||location.href.includes("youtube.com/embed/")||!c)return Reflect.construct(e,t,a);if(c.includes('"contentPlaybackContext"')||c.includes('"adSignalsInfo"')){const n=JSON.parse(c);if(!n.context?.client)return Reflect.construct(e,t,a);n.playbackContext&&y(n,n.playbackContext,r),n.playerRequest&&y(n,n.playerRequest.playbackContext,r),c=o(n),t[1].body=c}}catch(e){}return Reflect.construct(e,t,a)}};window.Request=new Proxy(window.Request,b)})();
|
||||
www.youtube.com#%#(()=>{const e="movie_player",t="ytd-watch-flexy[player-unavailable]",r=`#${e} > .ytp-error`,n="yt-playability-error-supported-renderers#error-screen:has(>*)",a='yt-playability-error-supported-renderers#error-screen a[href^="//support.google.com/youtube/answer/2802245"]',o="pyv",c="param",l="client_screen",i="ad_type",s="none";let y=c;const d=new Set,u=()=>{const t=document.getElementById(e),r=window.location.search,n=new URLSearchParams(r).get("v")||t?.getVideoData?.().video_id,a=new URLSearchParams(r).get("t")??"0";return{videoId:n,timeInSeconds:parseInt(a,10)}},p=()=>{b();const t=document.getElementById(e);if(t&&"function"==typeof t.loadVideoById)try{const{videoId:e,timeInSeconds:r}=u();t.loadVideoById(e,r)}catch(e){}},m=(()=>{let e=null,t=null,r=0;return n=>{try{if(!n)return!1;const{videoId:a}=u();return!!a&&(e===a&&t===n?r++:(e=a,t=n,r=1),r>=2&&(r=0,!0))}catch(e){return!1}}})(),f=e=>{y=e},b=()=>{const r=document.getElementById(e),o=document.querySelector(n),c=document.querySelector("yt-playability-error-supported-renderers.ytdMiniplayerPlayerContainerPlayabilityError:has(>*)"),l=document.querySelector(t),i=document.querySelector(a);r&&!i&&(l||c)&&(o?.style.setProperty("display","none","important"),c?.style.setProperty("display","none","important"),l?.removeAttribute("player-unavailable"))},v=e=>{(e.playbackContext||e.playerRequest)&&delete e.context?.client?.configInfo?.appInstallData},x=(e,t,r)=>{try{if(!e||!t||!r)return;if(r===c&&"CHANNEL"!==e.context?.client?.clientScreen)return e.params?.startsWith("yAEB")||(e.params=`yAEB${e.params?e.params:""}`),e.playerRequest&&!e.playerRequest.params?.startsWith("yAEB")&&(e.playerRequest.params=`yAEB${e.playerRequest.params?e.playerRequest.params:""}`),e.playbackContext&&!e.playbackContext.params?.startsWith("yAEB")&&(e.playbackContext.params=`yAEB${e.playbackContext.params?e.playbackContext.params:""}`),void v(e);if(r===o&&"CHANNEL"!==e.context?.client?.clientScreen&&!t.params?.startsWith("yAEB"))return t.adPlaybackContext={pyv:!0},void v(e);if(r===l&&"WEB"===e.context?.client?.clientName)return e.context.client.clientScreen="CHANNEL",void v(e);if(r===i)return t.adPlaybackContext={adType:"AD_TYPE_INSTREAM"},void v(e);if(r===s)return void delete t.adPlaybackContext}catch(e){}};(()=>{const e={apply:(e,t,r)=>{try{let n=r[0];if(!n||location.href.includes("youtube.com/tv")||location.href.includes("youtube.com/embed/"))return Reflect.apply(e,t,r);const a=Array.isArray(n),o=a?n[0]:n;if("string"!=typeof o)return Reflect.apply(e,t,r);if(!o.includes('"contentPlaybackContext"')&&!o.includes('"adSignalsInfo"'))return Reflect.apply(e,t,r);const c=JSON.parse(o);if(!c.context?.client)return Reflect.apply(e,t,r);c.playbackContext&&x(c,c.playbackContext,y),c.playerRequest&&x(c,c.playerRequest.playbackContext,y);const l=JSON.stringify(c);a?r[0][0]=l:r[0]=l}catch(e){}return Reflect.apply(e,t,r)}};window.XMLHttpRequest.prototype.send=new Proxy(window.XMLHttpRequest.prototype.send,e)})();const S=document.documentElement;new MutationObserver((()=>{if(document.querySelector(n)&&b(),!(()=>{const o=document.getElementById(e),c=document.querySelector(r),l=document.querySelector(n),i=document.querySelector(t),s=document.querySelector(a);if(!o||s)return!1;const y=o.getVideoData?.();return(l||i||c)&&null!=y?.errorCode})())return;const{videoId:v}=u();(e=>{if(e)for(const t of d)t!==e&&d.delete(t)})(v),(()=>{if(y===c){if(!m(o))return void p();f(o),p()}else if(y===o){if(!m(l))return void p();f(l),p()}else if(y===l){if(!m(i))return void p();f(i),p()}else if(y===i){if(!m(s))return void p();f(s),p()}else if(y===s){const{videoId:e}=u();if(!e||d.has(e))return void b();d.add(e),p()}})()})).observe(S,{attributes:!0,childList:!0,subtree:!0})})();
|
||||
www.youtube.com#%#(()=>{const e="pyv",t="param_first",a="param_second",n="client_screen",c="ad_type",r="none",o="yAEB",l="8AUB",i="CHANNEL",p=t;let s=p,y=null;const u=window.JSON.stringify,d=e=>{s=e};(()=>{try{const e=Object.getOwnPropertyDescriptor(window.JSON,"parse");return!!e&&e.writable}catch(e){return!1}})()||((()=>{const e={apply:(e,t,a)=>{try{const e=t;e?.includes('"minimumPlaybackRate":100,"maximumPlaybackRate":100')&&(t=e.replace('"minimumPlaybackRate":100,"maximumPlaybackRate":100','"minimumPlaybackRate":25,"maximumPlaybackRate":200'))}catch(e){}return Reflect.apply(e,t,a)}};window.String.prototype.replace=new Proxy(window.String.prototype.replace,e)})(),d(n));const f=e=>{(e.playbackContext||e.playerRequest)&&delete e.context?.client?.configInfo?.appInstallData},b=(s,u,b)=>{try{if(!s||!u||!b)return;if((e=>{const t=e?.videoId;t&&(y&&y!==t&&d(p),y=t)})(s),b===t&&s.context?.client?.clientScreen!==i)return s.params!==o&&(s.params=o),s.playerRequest&&s.playerRequest.params!==o&&(s.playerRequest.params=o),s.playbackContext&&s.playbackContext.params!==o&&(s.playbackContext.params=o),void f(s);if(b===a&&s.context?.client?.clientScreen!==i)return s.params!==l&&(s.params=l),s.playerRequest&&s.playerRequest.params!==l&&(s.playerRequest.params=l),s.playbackContext&&s.playbackContext.params!==l&&(s.playbackContext.params=l),s.playlistId||(s.context.client.clientScreen=i),void f(s);if(!(b!==e||s.context?.client?.clientScreen===i||u.params?.startsWith(o)&&u.params?.startsWith(l)))return u.adPlaybackContext={pyv:!0},void f(s);if(b===n&&"WEB"===s.context?.client?.clientName)return s.context.client.clientScreen=i,void f(s);if(b===c)return u.adPlaybackContext={adType:"AD_TYPE_INSTREAM"},void f(s);if(b===r)return void delete u.adPlaybackContext}catch(e){}},m=["playerErrorMessageRenderer","UNPLAYABLE"],x={apply:(o,l,i)=>{if(location.href.includes("/shorts/")||location.href.includes("youtube.com/tv")||location.href.includes("youtube.com/embed/")||s===r)return Reflect.apply(o,l,i);let p;try{if(p=Reflect.apply(o,l,i),!p.responseContext&&!p.playabilityStatus)return p;const y=u(p);return m.some((e=>y.includes(e)))&&!y.includes("CONTENT_CHECK_REQUIRED")?s===t?(d(a),p):s===a?(d(e),p):s===e?(d(n),p):s===n?(d(c),p):(d(r),p):(s===c&&p.playerConfig?.granularVariableSpeedConfig&&(p.playerConfig.granularVariableSpeedConfig.maximumPlaybackRate=200,p.playerConfig.granularVariableSpeedConfig.minimumPlaybackRate=25),p)}catch(e){}return p}};window.JSON.parse=new Proxy(window.JSON.parse,x);const R={apply:(e,t,a)=>{if(location.href.includes("/shorts/")||location.href.includes("youtube.com/tv")||location.href.includes("youtube.com/embed/"))return Reflect.apply(e,t,a);try{let n=a[0];if(n&&(n.includes('"contentPlaybackContext"')||n.includes('"adSignalsInfo"'))){const c=JSON.parse(n);if(!c.context?.client)return Reflect.apply(e,t,a);c.playbackContext&&b(c,c.playbackContext,s),c.playerRequest&&b(c,c.playerRequest.playbackContext,s),n=u(c),a[0]=n}}catch(e){}return Reflect.apply(e,t,a)}};window.TextEncoder.prototype.encode=new Proxy(window.TextEncoder.prototype.encode,R);const C={apply:(e,t,a)=>{if(location.href.includes("/shorts/")||location.href.includes("youtube.com/tv")||location.href.includes("youtube.com/embed/"))return Reflect.apply(e,t,a);try{const n=a[0];if(!n?.context?.client)return Reflect.apply(e,t,a);n.playbackContext&&void 0===n.playbackContext.adPlaybackContext&&b(n,n.playbackContext,s),n.playerRequest&&void 0===n.playerRequest.playbackContext.adPlaybackContext&&b(n,n.playerRequest.playbackContext,s),a[0]=n}catch(e){}return Reflect.apply(e,t,a)}};window.JSON.stringify=new Proxy(window.JSON.stringify,C);const k={construct:(e,t,a)=>{try{const n=t[0];let c=t[1]?.body;if(!n?.includes("youtubei")||location.href.includes("/shorts/")||location.href.includes("youtube.com/tv")||location.href.includes("youtube.com/embed/")||!c)return Reflect.construct(e,t,a);if(c.includes('"contentPlaybackContext"')||c.includes('"adSignalsInfo"')){const n=JSON.parse(c);if(!n.context?.client)return Reflect.construct(e,t,a);n.playbackContext&&b(n,n.playbackContext,s),n.playerRequest&&b(n,n.playerRequest.playbackContext,s),c=u(n),t[1].body=c}}catch(e){}return Reflect.construct(e,t,a)}};window.Request=new Proxy(window.Request,k)})();
|
||||
www.youtube.com#%#(()=>{const e="movie_player",t="ytd-watch-flexy[player-unavailable]",r=`#${e} > .ytp-error`,n="yt-playability-error-supported-renderers#error-screen:has(>*)",o='yt-playability-error-supported-renderers#error-screen a[href^="//support.google.com/youtube/answer/2802245"]',a="pyv",c="param_first",l="param_second",i="client_screen",s="ad_type",y="none",d="yAEB",p="8AUB",u="CHANNEL",m=c;let f=m,b=null;const v=new Set,x=()=>{const t=document.getElementById(e),r=window.location.search,n=new URLSearchParams(r).get("v")||t?.getVideoData?.().video_id,o=new URLSearchParams(r).get("t")??"0";return{videoId:n,timeInSeconds:parseInt(o,10)}},S=()=>{R();const t=document.getElementById(e);if(t&&"function"==typeof t.loadVideoById)try{const{videoId:e,timeInSeconds:r}=x();t.loadVideoById(e,r)}catch(e){}},q=(()=>{let e=null,t=null,r=0;return n=>{try{if(!n)return!1;const{videoId:o}=x();return!!o&&(e===o&&t===n?r++:(e=o,t=n,r=1),r>=2&&(r=0,!0))}catch(e){return!1}}})(),I=e=>{f=e},R=()=>{const r=document.getElementById(e),a=document.querySelector(n),c=document.querySelector("yt-playability-error-supported-renderers.ytdMiniplayerPlayerContainerPlayabilityError:has(>*)"),l=document.querySelector(t),i=document.querySelector(o);r&&!i&&(l||c)&&(a?.style.setProperty("display","none","important"),c?.style.setProperty("display","none","important"),l?.removeAttribute("player-unavailable"))},h=e=>{(e.playbackContext||e.playerRequest)&&delete e.context?.client?.configInfo?.appInstallData},C=(e,t,r)=>{try{if(!e||!t||!r)return;if((e=>{const t=e?.videoId;t&&(b&&b!==t&&I(m),b=t)})(e),r===c&&e.context?.client?.clientScreen!==u)return e.params!==d&&(e.params=d),e.playerRequest&&e.playerRequest.params!==d&&(e.playerRequest.params=d),e.playbackContext&&e.playbackContext.params!==d&&(e.playbackContext.params=d),void h(e);if(r===l&&e.context?.client?.clientScreen!==u)return e.params!==p&&(e.params=p),e.playerRequest&&e.playerRequest.params!==p&&(e.playerRequest.params=p),e.playbackContext&&e.playbackContext.params!==p&&(e.playbackContext.params=p),e.playlistId||(e.context.client.clientScreen=u),void h(e);if(!(r!==a||e.context?.client?.clientScreen===u||t.params?.startsWith(d)&&t.params?.startsWith(p)))return t.adPlaybackContext={pyv:!0},void h(e);if(r===i&&"WEB"===e.context?.client?.clientName)return e.context.client.clientScreen=u,void h(e);if(r===s)return t.adPlaybackContext={adType:"AD_TYPE_INSTREAM"},void h(e);if(r===y)return void delete t.adPlaybackContext}catch(e){}};(()=>{const e={apply:(e,t,r)=>{try{let n=r[0];if(!n||location.href.includes("youtube.com/tv")||location.href.includes("youtube.com/embed/"))return Reflect.apply(e,t,r);const o=Array.isArray(n),a=o?n[0]:n;if("string"!=typeof a)return Reflect.apply(e,t,r);if(!a.includes('"contentPlaybackContext"')&&!a.includes('"adSignalsInfo"'))return Reflect.apply(e,t,r);const c=JSON.parse(a);if(!c.context?.client)return Reflect.apply(e,t,r);c.playbackContext&&C(c,c.playbackContext,f),c.playerRequest&&C(c,c.playerRequest.playbackContext,f);const l=JSON.stringify(c);o?r[0][0]=l:r[0]=l}catch(e){}return Reflect.apply(e,t,r)}};window.XMLHttpRequest.prototype.send=new Proxy(window.XMLHttpRequest.prototype.send,e)})();const g=document.documentElement;new MutationObserver((()=>{if(document.querySelector(n)&&R(),!(()=>{const a=document.getElementById(e),c=document.querySelector(r),l=document.querySelector(n),i=document.querySelector(t),s=document.querySelector(o);if(!a||s)return!1;const y=a.getVideoData?.();return(l||i||c)&&null!=y?.errorCode})())return;const{videoId:d}=x();(e=>{if(e)for(const t of v)t!==e&&v.delete(t)})(d),(()=>{if(f===c){if(!q(l))return void S();I(l),S()}else if(f===l){if(!q(a))return void S();I(a),S()}else if(f===a){if(!q(i))return void S();I(i),S()}else if(f===i){if(!q(s))return void S();I(s),S()}else if(f===s){if(!q(y))return void S();I(y),S()}else if(f===y){const{videoId:e}=x();if(!e||v.has(e))return void R();v.add(e),S()}})()})).observe(g,{attributes:!0,childList:!0,subtree:!0})})();
|
||||
! Fix ads on https://www.youtube.com/shorts/
|
||||
! https://github.com/AdguardTeam/AdguardFilters/issues/172033#issuecomment-1991263854
|
||||
! TODO: remove the hints and JavaScript rule when Safari uses the latest scriptlets library (v2.2.7 or above)
|
||||
|
||||
Reference in New Issue
Block a user