From e53886277fa3671117a653c59057285d8af4d342 Mon Sep 17 00:00:00 2001 From: xmcp Date: Mon, 8 Apr 2024 01:40:54 +0800 Subject: [PATCH] fix firefox iframe player not working --- Gruntfile.js | 2 +- pakkujs/assets/xhr_hook_injector.js | 6 ++++++ pakkujs/core/main.ts | 9 +-------- pakkujs/core/post_combine.ts | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 pakkujs/assets/xhr_hook_injector.js diff --git a/Gruntfile.js b/Gruntfile.js index 120ddf5..26286d8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -13,7 +13,7 @@ function firefox_manifest(src, path) { // https://bugzilla.mozilla.org/show_bug.cgi?id=1736575 for(let s of obj.content_scripts) if(s.world==='MAIN') { - s.js = []; // will be injected by content_script.js + s.js = ['/assets/xhr_hook_injector.js']; delete s.world; } diff --git a/pakkujs/assets/xhr_hook_injector.js b/pakkujs/assets/xhr_hook_injector.js new file mode 100644 index 0000000..288cbe2 --- /dev/null +++ b/pakkujs/assets/xhr_hook_injector.js @@ -0,0 +1,6 @@ +// used for firefox + +console.log('pakku: inject xhr hook'); +let sc = document.createElement('script'); +sc.src = chrome.runtime.getURL('/assets/xhr_hook.js'); +document.documentElement.appendChild(sc); \ No newline at end of file diff --git a/pakkujs/core/main.ts b/pakkujs/core/main.ts index d6b7ccc..efa6f1f 100644 --- a/pakkujs/core/main.ts +++ b/pakkujs/core/main.ts @@ -136,11 +136,4 @@ window.addEventListener('message',async function(event) { handle_task(url[0], url[1], sendResponse, local_config, tabid as int); } -},false); - -if(process.env.PAKKU_CHANNEL === 'firefox') { - console.log('pakku: inject xhr hook'); - let sc = document.createElement('script'); - sc.src = chrome.runtime.getURL('/assets/xhr_hook.js'); - document.documentElement.appendChild(sc); -} \ No newline at end of file +},false); \ No newline at end of file diff --git a/pakkujs/core/post_combine.ts b/pakkujs/core/post_combine.ts index b9548b9..3701bc8 100644 --- a/pakkujs/core/post_combine.ts +++ b/pakkujs/core/post_combine.ts @@ -239,7 +239,7 @@ export function post_combine(input: DanmuClusterOutput, prev_input: DanmuCluster } } - // it seems that hot colorful danmus have style may issues, so we remove the colorful if hot + // it seems that hot colorful danmus may have style issues, so we remove the colorful if hot if(dm.extra.proto_attr && (dm.extra.proto_attr & 4)) { dm.extra.proto_colorful = 0; }