| 1 |
- !function(){"use strict";const e=globalThis.document;if(e instanceof globalThis.Document){let n=e.createElement("script");n.src="data:,("+t.toString()+")()",(e.documentElement||e).appendChild(n),n.remove(),n=e.createElement("script"),n.textContent="("+t.toString()+")()",(e.documentElement||e).appendChild(n),n.remove()}function t(){"undefined"==typeof globalThis&&(window.globalThis=window);const e=globalThis.document,t=e=>globalThis.dispatchEvent(e),n=globalThis.CustomEvent,r=globalThis.FileReader,a=globalThis.Blob,o={family:"font-family",style:"font-style",weight:"font-weight",stretch:"font-stretch",unicodeRange:"unicode-range",variant:"font-variant",featureSettings:"font-feature-settings"};var s,i,l;if(s="single-file-request-get-adopted-stylesheets",i=e=>{const t=e.target.shadowRoot;if(t){const r=Array.from(t.adoptedStyleSheets).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n")));r.length&&e.target.dispatchEvent(new n("single-file-response-get-adopted-stylesheets",{detail:{adoptedStyleSheets:r}}))}},l={capture:!0},globalThis.addEventListener(s,i,l),globalThis.FontFace){const r=globalThis.FontFace;globalThis.FontFace=function(){return c(...arguments).then((e=>t(new n("single-file-new-font-face",{detail:e})))),new r(...arguments)},globalThis.FontFace.prototype=r.prototype,globalThis.FontFace.toString=function(){return"function FontFace() { [native code] }"};const a=e.fonts.delete;e.fonts.delete=function(r){return c(r.family).then((e=>t(new n("single-file-delete-font",{detail:e})))),a.call(e.fonts,r)},e.fonts.delete.toString=function(){return"function delete() { [native code] }"};const o=e.fonts.clear;e.fonts.clear=function(){return t(new n("single-file-clear-fonts")),o.call(e.fonts)},e.fonts.clear.toString=function(){return"function clear() { [native code] }"}}async function c(e,t,n){const s={};return s["font-family"]=e,s.src=t,n&&Object.keys(n).forEach((e=>{o[e]&&(s[o[e]]=n[e])})),new Promise((e=>{if(s.src instanceof ArrayBuffer){const t=new r;t.readAsDataURL(new a([s.src])),t.addEventListener("load",(()=>{s.src="url("+t.result+")",e(s)}))}else e(s)}))}}const n=globalThis.browser,r=globalThis.document;if(r instanceof globalThis.Document&&n&&n.runtime&&n.runtime.getURL){const e=r.createElement("script");e.src=n.runtime.getURL("/lib/single-file-hooks-frames.js"),e.async=!1,(r.documentElement||r).appendChild(e),e.remove()}let a=new Map;browser.runtime.onMessage.addListener((e=>"singlefile.fetchFrame"==e.method&&window.frameId&&window.frameId==e.frameId?async function(e){try{const r=await(t=e.url,n={cache:"force-cache",headers:e.headers},window.fetch(t,n));return{status:r.status,headers:[...r.headers],array:Array.from(new Uint8Array(await r.arrayBuffer()))}}catch(e){return{error:e&&e.toString()}}var t,n}(e):"singlefile.fetchResponse"==e.method?async function(e){const t=a.get(e.requestId);t&&(e.error?(t.reject(new Error(e.error)),a.delete(e.requestId)):(e.truncated&&(t.array?t.array=t.array.concat(e.array):(t.array=e.array,a.set(e.requestId,t)),e.finished&&(e.array=t.array)),e.truncated&&!e.finished||(t.resolve({status:e.status,headers:{get:t=>e.headers&&e.headers[t]},arrayBuffer:async()=>new Uint8Array(e.array).buffer}),a.delete(e.requestId))));return{}}(e):void 0))}();
|