Skip to content

Commit

Permalink
💡 Improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
younesaassila committed Jun 19, 2023
1 parent 25ae310 commit 6b9e3ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/content/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ window.addEventListener("message", onMessage);
function injectPageScript() {
// From https://stackoverflow.com/a/9517879
const script = document.createElement("script");
script.src = pageScriptURL; // (src/page/page.ts)
script.src = pageScriptURL; // src/page/page.ts
script.dataset.params = JSON.stringify({
workerScriptURL: workerScriptURL, // (src/page/worker.ts)
workerScriptURL: workerScriptURL, // src/page/worker.ts
});
script.onload = () => script.remove();
// ---------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions src/page/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const params = JSON.parse(document.currentScript.dataset.params);

window.fetch = getFetch({ scope: "page" });

// Inject custom worker script to intercept fetch requests made from workers and
// decide whether to proxy them or not.
window.Worker = class Worker extends window.Worker {
constructor(scriptURL: string | URL, options?: WorkerOptions) {
const url = scriptURL.toString();
Expand All @@ -25,6 +23,11 @@ window.Worker = class Worker extends window.Worker {
);
script = `importScripts("${url}");`; // Will fail on Firefox Nightly.
}
// ---------------------------------------
// 🦊 Attention Firefox Addon Reviewer 🦊
// ---------------------------------------
// Please note that this does NOT involve remote code execution. The injected script is bundled
// with the extension. Additionally, there is no custom Content Security Policy (CSP) in use.
const newScript = `
try {
importScripts("${params.workerScriptURL}");
Expand Down

0 comments on commit 6b9e3ba

Please sign in to comment.