Rules-For-Quantumult-X/Scripts/AdBlock/Other/Youtube.min.js

6 lines
128 KiB
JavaScript
Raw Normal View History

// Author Maasea Build: 2023/12/15 19:46:49
(()=>{(function(l){function e(){}function t(){}var n=String.fromCharCode,i={}.toString,r=i.call(l.SharedArrayBuffer),f=i(),s=l.Uint8Array,o=s||Array,a=s?ArrayBuffer:o,u=a.isView||function(B){return B&&"length"in B},g=i.call(a.prototype);a=t.prototype;var k=l.TextEncoder,m=new(s?Uint16Array:o)(32);e.prototype.decode=function(B){if(!u(B)){var L=i.call(B);if(L!==g&&L!==r&&L!==f)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");B=s?new o(B):B||[]}for(var N=L="",w=0,R=B.length|0,le=R-32|0,O,W,$=0,J=0,D,j=0,S=-1;w<R;){for(O=w<=le?32:R-w|0;j<O;w=w+1|0,j=j+1|0){switch(W=B[w]&255,W>>4){case 15:if(D=B[w=w+1|0]&255,D>>6!==2||247<W){w=w-1|0;break}$=(W&7)<<6|D&63,J=5,W=256;case 14:D=B[w=w+1|0]&255,$<<=6,$|=(W&15)<<6|D&63,J=D>>6===2?J+4|0:24,W=W+256&768;case 13:case 12:D=B[w=w+1|0]&255,$<<=6,$|=(W&31)<<6|D&63,J=J+7|0,w<R&&D>>6===2&&$>>J&&1114112>$?(W=$,$=$-65536|0,0<=$&&(S=($>>10)+55296|0,W=($&1023)+56320|0,31>j?(m[j]=S,j=j+1|0,S=-1):(D=S,S=W,W=D))):(W>>=8,w=w-W-1|0,W=65533),$=J=0,O=w<=le?32:R-w|0;default:m[j]=W;continue;case 11:case 10:case 9:case 8:}m[j]=65533}if(N+=n(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],m[8],m[9],m[10],m[11],m[12],m[13],m[14],m[15],m[16],m[17],m[18],m[19],m[20],m[21],m[22],m[23],m[24],m[25],m[26],m[27],m[28],m[29],m[30],m[31]),32>j&&(N=N.slice(0,j-32|0)),w<R){if(m[0]=S,j=~S>>>31,S=-1,N.length<L.length)continue}else S!==-1&&(N+=n(S));L+=N,N=""}return L},a.encode=function(B){B=B===void 0?"":""+B;var L=B.length|0,N=new o((L<<1)+8|0),w,R=0,le=!s;for(w=0;w<L;w=w+1|0,R=R+1|0){var O=B.charCodeAt(w)|0;if(127>=O)N[R]=O;else{if(2047>=O)N[R]=192|O>>6;else{e:{if(55296<=O)if(56319>=O){var W=B.charCodeAt(w=w+1|0)|0;if(56320<=W&&57343>=W){if(O=(O<<10)+W-56613888|0,65535<O){N[R]=240|O>>18,N[R=R+1|0]=128|O>>12&63,N[R=R+1|0]=128|O>>6&63,N[R=R+1|0]=128|O&63;continue}break e}O=65533}else 57343>=O&&(O=65533);!le&&w<<1<R&&w<<1<(R-7|0)&&(le=!0,W=new o(3*L),W.set(N),N=W)}N[R]=224|O>>12,N[R=R+1|0]=128|O>>6&63}N[R=R+1|0]=128|O&63}}return s?N.subarray(0,R):N.slice(0,R)},k||(l.TextDecoder=e,l.TextEncoder=t)})(globalThis);function ce(l){let e=typeof l;if(e=="object"){if(Array.isArray(l))return"array";if(l===null)return"null"}return e}function Ai(l){return l!==null&&typeof l=="object"&&!Array.isArray(l)}var M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),de=[];for(let l=0;l<M.length;l++)de[M[l].charCodeAt(0)]=l;de["-".charCodeAt(0)]=M.indexOf("+");de["_".charCodeAt(0)]=M.indexOf("/");function _i(l){let e=l.length*3/4;l[l.length-2]=="="?e-=2:l[l.length-1]=="="&&(e-=1);let t=new Uint8Array(e),n=0,i=0,r,f=0;for(let s=0;s<l.length;s++){if(r=de[l.charCodeAt(s)],r===void 0)switch(l[s]){case"=":i=0;case`
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(i){case 0:f=r,i=1;break;case 1:t[n++]=f<<2|(r&48)>>4,f=r,i=2;break;case 2:t[n++]=(f&15)<<4|(r&60)>>2,f=r,i=3;break;case 3:t[n++]=(f&3)<<6|r,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,n)}function Vi(l){let e="",t=0,n,i=0;for(let r=0;r<l.length;r++)switch(n=l[r],t){case 0:e+=M[n>>2],i=(n&3)<<4,t=1;break;case 1:e+=M[i|n>>4],i=(n&15)<<2,t=2;break;case 2:e+=M[i|n>>6],e+=M[n&63],t=0;break}return t&&(e+=M[i],e+="=",t==1&&(e+="=")),e}var c;(function(l){l.symbol=Symbol.for("protobuf-ts/unknown"),l.onRead=(t,n,i,r,f)=>{(e(n)?n[l.symbol]:n[l.symbol]=[]).push({no:i,wireType:r,data:f})},l.onWrite=(t,n,i)=>{for(let{no:r,wireType:f,data:s}of l.list(n))i.tag(r,f).raw(s)},l.list=(t,n)=>{if(e(t)){let i=t[l.symbol];return n?i.filter(r=>r.no==n):i}return[]},l.last=(t,n)=>l.list(t,n).slice(-1)[0];let e=t=>t&&Array.isArray(t[l.symbol])})(c||(c={}));var d;(function(l){l[l.Varint=0]="Varint",l[l.Bit64=1]="Bit64",l[l.LengthDelimited=2]="LengthDelimited",l[l.StartGroup=3]="StartGroup",l[l.EndGroup=4]="EndGroup",l[l.Bit32=5]="Bit32"})(d||(d={}));function vi(){let l=0,e=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(l|=(i&127)<<n,!(i&128))return this.assertBounds(),[l,e]}let t=this.buf[this.pos++];if(l|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[l,e];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<n,!(i&128))return this.assertBounds(),[l,e]}throw new Error("invalid varint")}function pe(l,e,t){for(let r=0;r<28;r=r+7){let f=l>>>r,s=!(!(f>>>7)&&e==0),o=(s?f|128:f)&255;if(t.push(o),!s)return}let n=l>>>28&15|(e&7)<<4,i=!!(e>>3);if(t.push((i?n|128:n)&255),!!i){for(let r=3;r<31;r=r+7){let f=e>>>r,s=!!(f>>>7),o=(s?f|128:f)&255;if(t.push(o),!s)return}t.push(e>>>31&1)}}var he=(1<<16)*(1<<16);function $e(l){let e=l[0]=="-";e&&(l=l.slice(1));let t=1e6,n=0,i=0;function r(f,s){let o=Number(l.slice(f,s));i*=t,n=n*t+o,n>=he&&(i=i+(n/he|0),n=n%he)}return r(-24,-18),r(-18,-12),r(-12,-6),r(-6),[e,n,i]}function ye(l,e){if(e<=2097151)return""+(he*e+(l>>>0));let t=l&16777215,n=(l>>>24|e<<8)>>>0&16777215,i=e>>16&65535,r=t+n*6777216+i*6710656,f=n+i*8147497,s=i*2,o=1e7;r>=o&&(f+=Math.floor(r/o),r%=o),f>=o&&(s+=Math.floor(f/o),f%=o);function a(u,g){let k=u?String(u):"";return g?"0000000".slice(k.length)+k:k}return a(s,0)+a(f,s)+a(r,1)}function Ce(l,e){if(l>=0){for(;l>127;)e.push(l&127|128),l=l>>>7;e.push(l)}else{for(let t=0;t<9;t++)e.push(l&127|128),l=l>>7;e.push(1)}}function Ki(){let l=this.buf[this.pos++],e=l&127;if(!(l&128))return this.assertBounds(),e;if(l=this.buf[this.pos++],e|=(l&127)<<7,!(l&128))return this.assertBounds(),e;if(l=this.buf[this.pos++],e|=(l&127)<<14,!(l&128))return this.assertBounds(),e;if(l=this.buf[this.pos++],e|=(l&127)<<21,!(l&128))return this.assertBounds(),e;l=this.buf[this.pos++],e|=(l&15)<<28;for(let t=5;l&128&&t<10;t++)l=this.buf[this.pos++];if(l&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function mr(){let l=new DataView(new ArrayBuffer(8));return globalThis.BigInt!==void 0&&typeof l.getBigInt64=="function"&&typeof l.getBigUint64=="function"&&typeof l.setBigInt64=="function"&&typeof l.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:l}:void 0}var I=mr();function Gi(l){if(!l)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var Ji=/^-?[0-9]+$/,Fe=(1<<16)*(1<<16),me=class{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*Fe+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},x=class extends me{static from(e){if(I)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=I.C(e);case"number":if(e===0)return this.ZERO;e=I.C(e);case"bigint":if(!e)return this.ZERO;if(e<I.UMIN)throw new Error("signed value for ulong");if(e>I.UMA
`),i=!0,o.length=0}),i||this.iterate(this.message,"staticLyric",(s,o)=>{n=s,t=s.staticLyric,o.length=0,i=!0}),!i)return;let r=Fr(t),f=await U.fetch({method:"GET",url:r});if(f.status===200&&f.body){let s=JSON.parse(f.body),o=" & Translated by Google",a=s[2].includes("zh");n.staticLyric?(n.staticLyric=s[0].map(u=>a?u[0]:u[1]+u[0]||"").join(`\r
`),this.iterate(this.message,"originText",(u,g)=>{u.originText+=o,g.length=0})):n.n13F1.length<=s[0].length&&(n.n13F1.forEach((u,g)=>{u.f1=a?s[0][g][0]:u.f1+`
${s[0][g][0]}`}),n.originText+=o),this.needProcess=!0}}},We=class extends G{constructor(e=fr,t="Next"){super(e,t)}pure(){return super.pure(),this}addTranslateTab(){this.iterate(this.message?.a1F7?.musicPlayRender,"items",(e,t)=>{let n=e.items.find(i=>i.tab.info?.browseInfo?.browseId.startsWith("MPLYt"));n&&(n.tab.name=n.tab.name+"\u21C4"),this.needProcess=!0,t.length=0})}},xe=class extends K{constructor(e=hr,t="Player"){super(e,t)}pure(){this.message.p1F7?.length&&(this.message.p1F7.length=0);let e=this.message?.p1F2?.p2F21?.p3F151635310;typeof e=="object"&&(e.pip=1);let t={p2F11:{p3F64657230:{backPlay:1}}};return typeof this.message?.p1F2=="object"&&Object.assign(this.message.p1F2,t),this.iterate(this.message,"captionTracks",(n,i)=>{let r=n.captionTracks;if(Array.isArray(r))for(let f of r)f.isTranslatable=!0;n.translationLanguages=[{languageCode:"de",languageName:{runs:[{text:"Deutsch"}]}},{languageCode:"ru",languageName:{runs:[{text:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"}]}},{languageCode:"fr",languageName:{runs:[{text:"Fran\xE7ais"}]}},{languageCode:"fil",languageName:{runs:[{text:"Filipino"}]}},{languageCode:"ko",languageName:{runs:[{text:"\uD55C\uAD6D\uC5B4"}]}},{languageCode:"ja",languageName:{runs:[{text:"\u65E5\u672C\u8A9E"}]}},{languageCode:"en",languageName:{runs:[{text:"English"}]}},{languageCode:"vi",languageName:{runs:[{text:"Ti\u1EBFng Vi\u1EC7t"}]}},{languageCode:"zh-Hant",languageName:{runs:[{text:"\u4E2D\u6587\uFF08\u7E41\u9AD4\uFF09"}]}},{languageCode:"zh-Hans",languageName:{runs:[{text:"\u4E2D\u6587\uFF08\u7B80\u4F53\uFF09"}]}},{languageCode:"und",languageName:{runs:[{text:"@VirgilClyne"}]}}],n?.defaultCaptionTrackIndex||(n.defaultCaptionTrackIndex=0),i.length=0}),this.needProcess=!0,this}},Oe=class extends G{constructor(e=ur,t="Search"){super(e,t)}},Pe=class extends K{constructor(e=cr,t="Shorts"){super(e,t)}pure(){let e=this.message.t1F2?.length;if(e)for(let t=e-1;t>=0;t--)this.message.t1F2[t].n2F1?.n3F139608561?.n4F8||(this.message.t1F2.splice(t,1),this.needProcess=!0);return this}},Ue=class extends K{constructor(e=dr,t="Guide"){super(e,t)}pure(){let e=["FEmusic_immersive","SPunlimited","FEuploads"];return this.iterate(this.message,"g3F1",t=>{for(let n=t.g3F1.length-1;n>=0;n--){let i=t.g3F1[n]?.iconRender?.browseId||t.g3F1[n]?.labelRender?.browseId;e.includes(i)&&(t.g3F1.splice(n,1),this.needProcess=!0)}}),this}},Ee=class extends K{constructor(e=pr,t="Setting"){super(e,t)}pure(){this.iterate(this.message,"num",t=>{if(t.num===10005){let n={f1:135,f2:20434,f3:2,st2F4:this.message.st1F10.st2F4},i={st4F61331416:{f15:0,st5F5:{st3F5:n,st6F81212182:{st7F1:{st8F1:{f1:151},f3:1}}},st5F6:{st3F5:n,st6F81212182:{st7F1:{st8F1:{f1:151},f3:0}}},st3F5:n}};t.st3F3.push(i)}});let e={st2F88478200:{f2:1,f3:1,st3F5:{f1:2,f2:20020,f3:8,st2F4:this.message.st1F10.st2F4},f6:0,f7:1,f8:1,f9:1,f10:1,f12:1}};return this.message.st1F6.push(JSON.parse(JSON.stringify(e))),e.st2F88478200.st3F5.f1=1,e.st2F88478200.st3F5.f3=9,this.message.st1F7=e,this.needProcess=!0,this}};var Rr=new Map([["browse",G],["next",We],["player",xe],["search",Oe],["reel_watch_sequence",Pe],["guide",Ue],["get_setting",Ee]]);function Mi(l){for(let[e,t]of Rr.entries())if(l.includes(e))return new t;return null}async function Nr(){let l=Mi(U.request.url);if(l)try{let e=U.response.bodyBytes;l.fromBinary(e).pure(),l instanceof G&&l.needTranslate&&await l.translate(),l.doneResponse()}catch(e){console.log(e.toString()),U.exit()}else U.msg("YouTube Enhance","\u811A\u672C\u9700\u8981\u66F4\u65B0","\u5916\u90E8\u8D44\u6E90 -> \u5168\u90E8\u66F4\u65B0"),U.exit()}Nr();})();