Skip to content

Commit 7b9551f

Browse files
authored
🔀 Merge pull request #494 from FrostCo/fix_crunchyroll
Fix crunchyroll
2 parents f251da4 + 85a9e21 commit 7b9551f

File tree

2 files changed

+1
-42
lines changed

2 files changed

+1
-42
lines changed

src/script/background.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -136,30 +136,10 @@ export default class Background {
136136
this.LOGGER.info('disabling tab once.', tabId);
137137
}
138138

139-
static async getGlobalVariable(variableName: string, sender, sendResponse) {
140-
const [{ result }] = await chrome.scripting.executeScript({
141-
func: this.getWindowVariable,
142-
args: [variableName],
143-
target: { tabId: sender.tab.id, frameIds: [sender.frameId] },
144-
world: 'MAIN',
145-
});
146-
sendResponse(result);
147-
}
148-
149139
static getTabOptions(storage: BackgroundStorage, tabId: number): TabStorageOptions {
150140
return storage.tabs[tabId] || this.newTabOptions(storage, tabId);
151141
}
152142

153-
// variableName Supports '.' notation for nested values: window.nested.value
154-
static getWindowVariable(variableName: string) {
155-
try {
156-
const properties = variableName.split('.');
157-
return properties.reduce((prev, curr) => prev && prev[curr], window);
158-
} catch {
159-
return null;
160-
}
161-
}
162-
163143
static async handleBackgroundDataRequest(request: Message, sender: chrome.runtime.MessageSender, sendResponse) {
164144
const storage = await this.loadBackgroundStorage();
165145
const tabId = request.source == this.Constants.MESSAGING.CONTEXT ? sender.tab.id : request.tabId;
@@ -284,11 +264,9 @@ export default class Background {
284264
} else if (request.fetch) {
285265
this.handleRequest(request.fetch, request.fetchMethod, sendResponse);
286266
return true; // return true when waiting on an async call
287-
} else if (request.globalVariable) {
288-
this.getGlobalVariable(request.globalVariable, sender, sendResponse);
289-
return true; // return true when waiting on an async call
290267
} else {
291268
this.onContextMessageElse(chromeAction, request, sender, sendResponse);
269+
return true; // return true when waiting on an async call
292270
}
293271
break;
294272

src/script/lib/helper.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,6 @@ export function getElements(selector: string, root: Document | HTMLElement | Sha
111111
}
112112
}
113113

114-
export function getGlobalVariable(code: string, id: string = 'APFData') {
115-
const script = document.createElement('script');
116-
script.id = id;
117-
script.textContent = `document.getElementById("${id}").textContent = JSON.stringify(${code})`;
118-
document.documentElement.appendChild(script);
119-
const result = document.querySelector(`script#${id}`).textContent;
120-
script.remove();
121-
return JSON.parse(result);
122-
}
123-
124-
export function getGlobalVariableFromBackground(globalVariable: string, source = 'context') {
125-
return new Promise((resolve, reject) => {
126-
const message: Message = { destination: 'background', globalVariable: globalVariable, source: source };
127-
chrome.runtime.sendMessage(message, (response) => {
128-
resolve(response);
129-
});
130-
});
131-
}
132-
133114
export function getParent(node: HTMLElement, level: number = 1): HTMLElement {
134115
if (!node) {
135116
return null;

0 commit comments

Comments
 (0)