From c6e7d728f1e298168258d64e7d5a9ddbe35617c0 Mon Sep 17 00:00:00 2001 From: msojocs Date: Sun, 28 Aug 2022 18:50:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=BC=AB=E6=B8=B8=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.MD | 4 ++++ extensions/area_unlimit/hook.js | 17 ++++++++++++----- extensions/area_unlimit/hook/index.js | 2 +- extensions/area_unlimit/hook/player.js | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 3fa25cc..c1bb24b 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,3 +1,7 @@ +# v1.5.0-2 / 2022-08-28 + + - fix: 漫游页面无法加载 + # v1.5.0-1 / 2022-08-21 - bilibili: update to v1.5.0.1184 diff --git a/extensions/area_unlimit/hook.js b/extensions/area_unlimit/hook.js index 1b18099..23d1471 100644 --- a/extensions/area_unlimit/hook.js +++ b/extensions/area_unlimit/hook.js @@ -2,6 +2,13 @@ console.log("=====HOOK=====") const url = new URL(location.href) const fileName = url.pathname.substring(1).split('.')[0] +const URLS = { + commonJS: chrome.extension.getURL(`hook/common.js`), + commonCSS: chrome.extension.getURL(`hook/common.css`), + RoamingPage: chrome.extension.getURL(`hook/RoamingPage.html`), + PlayerEnhance: chrome.extension.getURL(`hook/PlayerEnhance.html`), +} +const commonJSURL = chrome.extension.getURL(`hook/common.js`); var s = document.createElement('script'); s.src = chrome.extension.getURL(`hook/${fileName}.js`); (document.head || document.documentElement).appendChild(s); @@ -15,7 +22,7 @@ window.onload = ()=>{ if(searchIframe){ const searchDocument = searchIframe.contentWindow.document var commonJS = document.createElement('script'); - commonJS.src = chrome.extension.getURL(`hook/common.js`); + commonJS.src = URLS.commonJS; (searchDocument.head || searchDocument.documentElement).appendChild(commonJS); commonJS.onload = function () { commonJS.remove(); @@ -24,7 +31,7 @@ window.onload = ()=>{ } var commonJS = document.createElement('script'); -commonJS.src = chrome.extension.getURL(`hook/common.js`); +commonJS.src = commonJSURL; (document.head || document.documentElement).appendChild(commonJS); commonJS.onload = function () { commonJS.remove(); @@ -38,7 +45,7 @@ md5JS.onload = function () { var css = document.createElement('link'); css.rel = "stylesheet" -css.href = chrome.extension.getURL(`hook/common.css`); +css.href = chrome.extension.getURL(`/hook/common.css`); (document.head || document.documentElement).appendChild(css); // Event listener @@ -46,8 +53,8 @@ document.addEventListener('ROAMING_getURL', function (e) { // e.detail contains the transferred data (can be anything, ranging // from JavaScript objects to strings). // Do something, for example: - console.log(e.detail); - const roamingPageURL = chrome.extension.getURL(`hook/${e.detail}.html`); + console.log('hook ROAMING_getURL:', e.detail); + const roamingPageURL = URLS[e.detail]; document.dispatchEvent(new CustomEvent('ROAMING_sendURL', { detail: roamingPageURL // Some variable from Gmail. })); diff --git a/extensions/area_unlimit/hook/index.js b/extensions/area_unlimit/hook/index.js index c4bfa66..886341c 100644 --- a/extensions/area_unlimit/hook/index.js +++ b/extensions/area_unlimit/hook/index.js @@ -134,7 +134,7 @@ // e.detail contains the transferred data (can be anything, ranging // from JavaScript objects to strings). // Do something, for example: - console.log(e.detail); + console.log('index ROAMING_sendURL:', e.detail); if(e.detail.includes("RoamingPage")){ // 判断HTML为漫游页面 const roamingHTML = await HTTP_INDEX.get(e.detail) diff --git a/extensions/area_unlimit/hook/player.js b/extensions/area_unlimit/hook/player.js index bf972e0..0a2a2d8 100644 --- a/extensions/area_unlimit/hook/player.js +++ b/extensions/area_unlimit/hook/player.js @@ -232,7 +232,7 @@ console.log("====HOOK===PLAYER===="); // e.detail contains the transferred data (can be anything, ranging // from JavaScript objects to strings). // Do something, for example: - console.log('ROAMING_sendURL: ', e.detail); + console.log('player ROAMING_sendURL: ', e.detail); if(e.detail.includes("PlayerEnhance")){ const roamingHTML = await HTTP.get(e.detail) const container = document.createElement('div')