Skip to content

Commit

Permalink
fix: 漫游页面无法加载
Browse files Browse the repository at this point in the history
  • Loading branch information
msojocs committed Aug 28, 2022
1 parent 2aefa72 commit c6e7d72
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 12 additions & 5 deletions extensions/area_unlimit/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -38,16 +45,16 @@ 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
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.
}));
Expand Down
2 changes: 1 addition & 1 deletion extensions/area_unlimit/hook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion extensions/area_unlimit/hook/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

1 comment on commit c6e7d72

@msojocs
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#40

Please sign in to comment.