feat: add cross-browser browser.*/chrome.* shim; exclude test/ from builds
This commit is contained in:
@@ -1,4 +1,10 @@
|
|||||||
'use strict';
|
'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) {
|
function errMsg(err) {
|
||||||
return String((err && err.message) || err);
|
return String((err && err.message) || err);
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'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';
|
const MASTER_KEY = 'enabled';
|
||||||
|
|
||||||
async function isEnabled() {
|
async function isEnabled() {
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
'use strict';
|
'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 $ = (sel) => document.querySelector(sel);
|
||||||
|
|
||||||
const MASTER_KEY = 'enabled';
|
const MASTER_KEY = 'enabled';
|
||||||
|
|||||||
+2
-2
@@ -23,8 +23,8 @@ function collectFiles(srcDir, out = [], prefix = '') {
|
|||||||
const abs = path.join(srcDir, entry);
|
const abs = path.join(srcDir, entry);
|
||||||
const rel = prefix ? prefix + '/' + entry : entry;
|
const rel = prefix ? prefix + '/' + entry : entry;
|
||||||
if (entry === '.git' || entry === 'node_modules' || entry === 'dist' ||
|
if (entry === '.git' || entry === 'node_modules' || entry === 'dist' ||
|
||||||
entry === 'docs' || entry === 'scripts' || entry === 'manifest.json' ||
|
entry === 'docs' || entry === 'scripts' || entry === 'test' ||
|
||||||
entry.startsWith('.')) {
|
entry === 'manifest.json' || entry.startsWith('.')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (fs.statSync(abs).isDirectory()) collectFiles(abs, out, rel);
|
if (fs.statSync(abs).isDirectory()) collectFiles(abs, out, rel);
|
||||||
|
|||||||
Reference in New Issue
Block a user