Skip to content

Commit f93ce1a

Browse files
committed
declarativeNetRequestFeedback only in DEBUG/DEV
1 parent 7e734bd commit f93ce1a

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

Diff for: src/.types.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ declare var __: {
88
DEBUGLOG: typeof console.log,
99
DEBUGTRACE: typeof console.trace,
1010
DEBUGWARN: typeof console.warn,
11+
DEV: boolean,
1112
ENTRY: 'offscreen' | 'sw' | 'worker' | string | boolean,
1213
IS_BG: boolean,
1314
JS: string,

Diff for: src/js/dnr.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ function updateDNR(
2525
return this({addRules, removeRuleIds});
2626
}
2727

28-
if (__.MV3 && !__.ZIP && __.DEBUG) {
28+
if (__.MV3 && (__.DEBUG || __.DEV)) {
2929
DNR.onRuleMatchedDebug?.addListener(console.log.bind(null, 'DNR'));
3030
}

Diff for: src/manifest-mv3.json

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"alarms",
66
"contextMenus",
77
"declarativeNetRequestWithHostAccess",
8-
"declarativeNetRequestFeedback",
98
"identity",
109
"idle",
1110
"offscreen",

Diff for: tools/build-zip.js

-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ const TARGETS = [
5555
function patchManifest(str, target) {
5656
const [/*BUILD*/, /*FLAVOR*/, CHANNEL] = target.split('-');
5757
const mj = JSON.parse(str);
58-
const i = mj.permissions.indexOf('declarativeNetRequestFeedback');
59-
if (i >= 0) mj.permissions.splice(i, 1);
6058
if (CHANNEL) mj.name += ` (${CHANNEL})`;
6159
delete mj.key;
6260
return mj;

Diff for: webpack.config.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ const WebpackPatchBootstrapPlugin = require('./tools/webpack-patch-bootstrap');
1616
const {escapeForRe, getManifestOvrName, stripSourceMap, DEV, MANIFEST, ROOT} =
1717
require('./tools/util');
1818

19-
const GITHUB_ACTIONS = process.env.GITHUB_ACTIONS;
20-
const NODE_ENV = process.env.NODE_ENV;
19+
const {DEBUG, GITHUB_ACTIONS, NODE_ENV} = process.env;
2120
const [TARGET, ZIP] = NODE_ENV?.split(':') || [''];
2221
const [BUILD, FLAVOR, CHANNEL] = TARGET.split('-');
2322
const SRC = ROOT + 'src/';
@@ -75,7 +74,7 @@ const VARS = {
7574
BUILD,
7675
CLIENT_DATA: 'clientData', // hiding the global from IDE
7776
CM_PATH,
78-
DEBUG: process.env.DEBUG?.split(',').reduce((res, s) => res + DEBUGMASK[s], 1) || 0,
77+
DEBUG: DEBUG?.split(',').reduce((res, s) => res + DEBUGMASK[s], 1) || 0,
7978
DEV,
8079
ENTRY: false,
8180
IS_BG: false,
@@ -86,9 +85,9 @@ const VARS = {
8685
ZIP: !!ZIP,
8786
};
8887
const RAW_VARS = {
89-
DEBUGLOG: (process.env.DEBUG ? '' : 'null&&') + 'console.log',
90-
DEBUGTRACE: (process.env.DEBUG ? '' : 'null&&') + 'console.trace',
91-
DEBUGWARN: (process.env.DEBUG ? '' : 'null&&') + 'console.warn',
88+
DEBUGLOG: (DEBUG ? '' : 'null&&') + 'console.log',
89+
DEBUGTRACE: (DEBUG ? '' : 'null&&') + 'console.trace',
90+
DEBUGWARN: (DEBUG ? '' : 'null&&') + 'console.warn',
9291
KEEP_ALIVE: '1&&',
9392
};
9493
const BANNER = '{const global = this, window = global;';
@@ -314,6 +313,9 @@ function makeManifest(files) {
314313
if (MV3 && CHANNEL === 'beta' && parseInt(ver) === 2) {
315314
ver = base.version = 3 + ver.slice(1);
316315
}
316+
if (MV3 && (DEBUG || DEV)) {
317+
base.permissions.push('declarativeNetRequestFeedback');
318+
}
317319
if (GITHUB_ACTIONS) {
318320
delete base.key;
319321
childProcess.execSync(`echo "_VER=${ver}" >> $GITHUB_ENV`);

0 commit comments

Comments
 (0)