diff --git a/background.js b/background.js index d1a28c3..33e2db5 100644 --- a/background.js +++ b/background.js @@ -1,4 +1,10 @@ 'use strict'; +// Cross-browser API namespace. Firefox provides Promise-based `browser.*`; +// Chrome MV3 exposes `browser.*` too, but some builds only populate the +// `chrome.*` global. Alias to whichever is present. +if (typeof browser === 'undefined' || browser == null) { + var browser = (typeof chrome !== 'undefined' ? chrome : {}); +} function errMsg(err) { return String((err && err.message) || err); diff --git a/content.js b/content.js index 0da0d55..df2a3ad 100644 --- a/content.js +++ b/content.js @@ -1,6 +1,11 @@ (function () { 'use strict'; + // Cross-browser API namespace (see background.js). No-op in Firefox. + if (typeof browser === 'undefined' || browser == null) { + var browser = (typeof chrome !== 'undefined' ? chrome : {}); + } + const MASTER_KEY = 'enabled'; async function isEnabled() { diff --git a/popup.js b/popup.js index c601f31..0bcc0ef 100644 --- a/popup.js +++ b/popup.js @@ -1,5 +1,10 @@ 'use strict'; +// Cross-browser API namespace (see background.js). No-op in Firefox. +if (typeof browser === 'undefined' || browser == null) { + var browser = (typeof chrome !== 'undefined' ? chrome : {}); +} + const $ = (sel) => document.querySelector(sel); const MASTER_KEY = 'enabled'; diff --git a/scripts/build.js b/scripts/build.js index 4adce7e..3ac86e0 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -23,8 +23,8 @@ function collectFiles(srcDir, out = [], prefix = '') { const abs = path.join(srcDir, entry); const rel = prefix ? prefix + '/' + entry : entry; if (entry === '.git' || entry === 'node_modules' || entry === 'dist' || - entry === 'docs' || entry === 'scripts' || entry === 'manifest.json' || - entry.startsWith('.')) { + entry === 'docs' || entry === 'scripts' || entry === 'test' || + entry === 'manifest.json' || entry.startsWith('.')) { continue; } if (fs.statSync(abs).isDirectory()) collectFiles(abs, out, rel);