Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
Mlocik97 committed Mar 25, 2023
1 parent b9834f6 commit 37fcc3c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "cd src; zip -r ../output.zip *",
"test": "node test.js",
"lint": "rettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. .",
"check": "tsc -p ./jsconfig.json"
},
Expand Down
10 changes: 4 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const icon = chrome
// chrome
? chrome.runtime.getURL("/images/icon-rotate.png")
// firefox
// @ts-ignore
: browser.runtime.getURL("/images/icon-rotate.png");
// @ts-ignore
const { runtime } = chrome ? chrome : /** @type {chrome} */ (browser);

const icon = runtime.getURL("/images/icon-rotate.png")

/**
* adds button to toolbar, when episode is opened
Expand Down
6 changes: 2 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ const jsFile = fs.readFileSync("./src/index.js", {
const scriptElement = document.createElement("script");
scriptElement.textContent = jsFile

// replace `runtime.getURL` with url
.replace("icon = chrome", 'icon = "./images/icon-rotate.png"')
.replace('? chrome.runtime.getURL("/images/icon-rotate.png")', '')
.replace(': browser.runtime.getURL("/images/icon-rotate.png");', '');
// replace chrome object
.replace(/chrome/g, "{ runtime: { getURL: (s) => s } }")

document.head.append(scriptElement);

Expand Down

0 comments on commit 37fcc3c

Please sign in to comment.