diff --git a/config-overrides/index.js b/config-overrides/index.js
index e590cad49978..03646823acbf 100644
--- a/config-overrides/index.js
+++ b/config-overrides/index.js
@@ -48,16 +48,17 @@ const target = (argv => ({
WKWebview: (argv['wk-webview']),
}))(require('yargs').argv)
-if (target.Firefox) {
- polyfills = polyfills.filter(name => !name.includes('webextension-polyfill'))
-}
-
/**
* @param config {import("webpack").Configuration}
* @param env {'development' | 'production'}
* @returns {import("webpack").Configuration}
*/
function override(config, env) {
+ if (target.Firefox) {
+ polyfills = polyfills.filter(name => !name.includes('webextension-polyfill'))
+ polyfills.push(src('src/polyfill/permissions.js'))
+ }
+
// CSP bans eval
// And non-inline source-map not working
if (env === 'development') config.devtool = 'inline-source-map'
@@ -105,7 +106,10 @@ function override(config, env) {
function newPage(options = {}) {
let templateContent = fs.readFileSync(path.join(__dirname, './template.html'), 'utf8')
if (target.Firefox) {
- templateContent = templateContent.replace('', '')
+ templateContent = templateContent.replace(
+ '',
+ '',
+ )
}
return new HtmlWebpackPlugin({
templateContent,
diff --git a/src/polyfill/permissions.js b/src/polyfill/permissions.js
new file mode 100644
index 000000000000..b5e9418c21b9
--- /dev/null
+++ b/src/polyfill/permissions.js
@@ -0,0 +1,15 @@
+;(()=>{
+ if (!browser) return
+ if (browser.permissions) return
+ browser.permissions = {}
+ const requestedUrls = []
+ browser.permissions.request = ({origins}) => {
+ for (let i of origins) {
+ if (requestedUrls.indexOf(i) === -1) requestedUrls.push(i)
+ }
+ return Promise.resolve(true)
+ }
+ browser.permissions.getAll = () => {
+ return Promise.resolve({origins: requestedUrls})
+ }
+})()