Skip to content

Instantly share code, notes, and snippets.

@Yuki2718
Created August 2, 2024 04:42
Show Gist options
  • Save Yuki2718/1a962af14c72aff65e907d7750f45af4 to your computer and use it in GitHub Desktop.
Save Yuki2718/1a962af14c72aff65e907d7750f45af4 to your computer and use it in GitHub Desktop.
Test SSAP rules on Android
youtube.com##+js(set-trusted-types)
youtube.com##+js(trusted-rpnt, script, (function() {window.ytplayer=, '/*start*/(()=>{let t=document.location.href;let e=[];let n=[];let o=false;let r="";const i=Array.prototype.push;const a={apply:(t,r,a)=>{if(window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id&&a[0]&&a[0]!==window&&typeof a[0].start=="number"&&a[0].end&&a[0].namespace==="ssap"&&a[0].id){if(!o&&a[0]?.start===0&&!n.includes(a[0].id)){e.length=0;n.length=0;o=true;i.call(e,a[0]);i.call(n,a[0].id)}if(o&&a[0]?.start!==0&&!n.includes(a[0].id)){i.call(e,a[0]);i.call(n,a[0].id)}}return Reflect.apply(t,r,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);const a=Math.round(e.at(-1).end/1e3);const c=n.join(",");console.log(t.currentTime,r,i,a,"uBO");if(t.loop===false&&r!==c&&i&&i===a){const adsTime=e.at(-1).start/1e3;console.log(JSON.stringify(e),JSON.stringify(n),r,adsTime,t.currentTime,"uBO");if(t.currentTime<adsTime){t.currentTime=adsTime;o=false;r=c}}else if(t.loop===true&&i&&i===a){const adsTime=e.at(-1).start/1e3;if(t.currentTime<adsTime){t.currentTime=adsTime;o=false;r=c}}}};i();new MutationObserver((()=>{if(t!==document.location.href){t=document.location.href;e.length=0;n.length=0;o=false;i()}else{i()}})).observe(document,{childList:true,subtree:true})}))})();if(window.trustedTypes){const escapeHTMLPolicy=trustedTypes.createPolicy("myEscapePolicy",{createScript:string=>string.replace(/\/\*start\*\/(.*)\/\*end\*\//g,"")});document.currentScript.textContent=escapeHTMLPolicy.createScript(document.currentScript.textContent)}else{document.currentScript.textContent=document.currentScript.textContent.replace(/\/\*start\*\/(.*)\/\*end\*\//g,"")}/*end*/(function() {window.ytplayer=', sedCount, 1)
youtube.com##+js(nano-stb, [native code], 17000, 0.001)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment