Skip to content

Commit 588a8ac

Browse files
committed
add default noop rules for behind-the-scene scope
1 parent d122b4a commit 588a8ac

File tree

2 files changed

+45
-16
lines changed

2 files changed

+45
-16
lines changed

src/js/hnswitches.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ HnSwitches.prototype.toString = function() {
277277

278278
/******************************************************************************/
279279

280-
HnSwitches.prototype.fromString = function(text) {
280+
HnSwitches.prototype.fromString = function(text, append) {
281281
var lineIter = new µBlock.LineIterator(text);
282-
this.reset();
282+
if ( append !== true ) { this.reset(); }
283283
while ( lineIter.eot() === false ) {
284284
this.addFromRuleParts(lineIter.next().trim().split(/\s+/));
285285
}

src/js/start.js

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,38 @@ var onVersionReady = function(lastVersion) {
115115
// certainly cause too much breakage in Firefox legacy given that uBO can
116116
// see ALL network requests.
117117
// Remove when everybody is beyond 1.15.19b8.
118-
if ( vAPI.firefox === undefined ) {
119-
var match = /^(\d+)\.(\d+)\.(\d+)(?:\D+(\d+))?/.exec(lastVersion);
120-
if ( match !== null ) {
121-
var v1 =
122-
parseInt(match[1], 10) * 1000 * 1000 * 1000 +
123-
parseInt(match[2], 10) * 1000 * 1000 +
124-
parseInt(match[3], 10) * 1000 +
125-
(match[4] ? parseInt(match[4], 10) : 0);
126-
if ( v1 <= 1015019008 ) {
127-
µb.toggleNetFilteringSwitch('http://behind-the-scene/', '', true);
128-
}
118+
(function patch1015019008(s) {
119+
if ( vAPI.firefox !== undefined ) { return; }
120+
var match = /^(\d+)\.(\d+)\.(\d+)(?:\D+(\d+))?/.exec(s);
121+
if ( match === null ) { return; }
122+
var v =
123+
parseInt(match[1], 10) * 1000 * 1000 * 1000 +
124+
parseInt(match[2], 10) * 1000 * 1000 +
125+
parseInt(match[3], 10) * 1000 +
126+
(match[4] ? parseInt(match[4], 10) : 0);
127+
if ( /rc\d+$/.test(s) ) { v += 100; }
128+
if ( v > 1015019008 ) { return; }
129+
if ( µb.getNetFilteringSwitch('http://behind-the-scene/') !== true ) {
130+
return;
129131
}
130-
}
132+
var fwRules = [
133+
'behind-the-scene * * noop',
134+
'behind-the-scene * image noop',
135+
'behind-the-scene * 3p noop',
136+
'behind-the-scene * inline-script noop',
137+
'behind-the-scene * 1p-script noop',
138+
'behind-the-scene * 3p-script noop',
139+
'behind-the-scene * 3p-frame noop'
140+
].join('\n');
141+
µb.sessionFirewall.fromString(fwRules, true);
142+
µb.permanentFirewall.fromString(fwRules, true);
143+
µb.savePermanentFirewallRules();
144+
µb.hnSwitches.fromString([
145+
'behind-the-scene: no-large-media false'
146+
].join('\n'), true);
147+
µb.saveHostnameSwitches();
148+
µb.toggleNetFilteringSwitch('http://behind-the-scene/', '', true);
149+
})(lastVersion);
131150

132151
vAPI.storage.set({ version: vAPI.app.version });
133152
};
@@ -271,9 +290,19 @@ var fromFetch = function(to, fetched) {
271290
var onSelectedFilterListsLoaded = function() {
272291
var fetchableProps = {
273292
'compiledMagic': '',
274-
'dynamicFilteringString': 'behind-the-scene * 3p noop\nbehind-the-scene * 3p-frame noop',
293+
'dynamicFilteringString': [
294+
'behind-the-scene * * noop',
295+
'behind-the-scene * image noop',
296+
'behind-the-scene * 3p noop',
297+
'behind-the-scene * inline-script noop',
298+
'behind-the-scene * 1p-script noop',
299+
'behind-the-scene * 3p-script noop',
300+
'behind-the-scene * 3p-frame noop'
301+
].join('\n'),
275302
'urlFilteringString': '',
276-
'hostnameSwitchesString': '',
303+
'hostnameSwitchesString': [
304+
'behind-the-scene: no-large-media false'
305+
].join('\n'),
277306
'lastRestoreFile': '',
278307
'lastRestoreTime': 0,
279308
'lastBackupFile': '',

0 commit comments

Comments
 (0)