Skip to content

Commit

Permalink
Fix VAFT conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
younesaassila committed Jan 30, 2024
1 parent 51f7e4a commit ee37296
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ttv-lol-pro",
"version": "2.3.2",
"version": "2.3.3",
"description": "TTV LOL PRO removes most livestream ads from Twitch.",
"@parcel/bundler-default": {
"minBundles": 10000000,
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.chromium.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "TTV LOL PRO",
"description": "TTV LOL PRO removes most livestream ads from Twitch.",
"homepage_url": "https://github.com/younesaassila/ttv-lol-pro",
"version": "2.3.2",
"version": "2.3.3",
"background": {
"service_worker": "background/background.ts",
"type": "module"
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "TTV LOL PRO",
"description": "TTV LOL PRO removes most livestream ads from Twitch.",
"homepage_url": "https://github.com/younesaassila/ttv-lol-pro",
"version": "2.3.2",
"version": "2.3.3",
"background": {
"scripts": ["background/background.ts"],
"persistent": false
Expand Down
22 changes: 17 additions & 5 deletions src/page/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ window.Worker = class Worker extends window.Worker {
script = xhr.responseText;
} else {
console.warn(`[TTV LOL PRO] Failed to fetch script: ${xhr.statusText}`);
script = `importScripts("${fullUrl}");`; // Will fail on Firefox Nightly.
script = `importScripts('${fullUrl}');`; // Will fail on Firefox Nightly.
}
// ---------------------------------------
// 🦊 Attention Firefox Addon Reviewer 🦊
Expand All @@ -69,18 +69,30 @@ window.Worker = class Worker extends window.Worker {
const newScript = `
var getParams = () => '${JSON.stringify(params)}';
try {
importScripts("${params.workerScriptURL}");
importScripts('${params.workerScriptURL}');
} catch (error) {
console.error("[TTV LOL PRO] Failed to load worker script: ${
console.error('[TTV LOL PRO] Failed to load script: ${
params.workerScriptURL
}:", error);
}:', error);
}
${script}
`;
const newScriptURL = URL.createObjectURL(
new Blob([newScript], { type: "text/javascript" })
);
super(newScriptURL, options);
// Required for VAFT compatibility.
const wrapperScript = `
try {
importScripts('${newScriptURL}');
} catch (error) {
console.warn('[TTV LOL PRO] Failed to wrap script: ${newScriptURL}:', error);
${newScript}
}
`;
const wrapperScriptURL = URL.createObjectURL(
new Blob([wrapperScript], { type: "text/javascript" })
);
super(wrapperScriptURL, options);
this.addEventListener("message", event => {
if (
event.data?.type === MessageType.ContentScriptMessage ||
Expand Down

0 comments on commit ee37296

Please sign in to comment.