-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It looks like that the polyfill is no longer required for Manifest v3. [^1] However, for a better developer experience, we keep the TypeScript definitions and use a little workaround for the global "browser" namespace. [^1]: mozilla/webextension-polyfill#329
- Loading branch information
1 parent
a275aac
commit efd0003
Showing
8 changed files
with
36 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
env: | ||
browser: true | ||
es2021: true | ||
node: true | ||
webextensions: true | ||
|
||
extends: | ||
- "eslint:recommended" | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
import { action, permissions, tabs } from "webextension-polyfill"; | ||
|
||
action.onClicked.addListener(async (tab) => { | ||
browser.action.onClicked.addListener(async (tab) => { | ||
const u = new URL(tab.url); | ||
const perms = { origins: [`${u.origin}/*`] }; | ||
const hasPermissions = await permissions.contains(perms); | ||
const hasPermissions = await browser.permissions.contains(perms); | ||
if (!hasPermissions) { | ||
await permissions.request(perms); | ||
await tabs.reload(tab.id); | ||
await browser.permissions.request(perms); | ||
await browser.tabs.reload(tab.id); | ||
} | ||
|
||
action.setPopup({ popup: "options/options.html" }); | ||
action.setTitle({ title: "Configure ProToots" }); | ||
browser.action.setPopup({ popup: "options/options.html" }); | ||
browser.action.setTitle({ title: "Configure ProToots" }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// This file is used to have IntelliSense enabled automatically for the global "browser" namespace. | ||
|
||
import module = require("@types/webextension-polyfill"); | ||
export = module; | ||
export as namespace browser; | ||
|
||
declare global { | ||
interface Window { | ||
browser: typeof module; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters