2015-11-23 13:52:50 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
|
|
|
|
uBlock Origin - a browser extension to block requests.
|
2018-08-11 16:39:43 +02:00
|
|
|
Copyright (C) 2015-present Raymond Hill
|
2015-11-23 13:52:50 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
|
|
|
|
|
|
|
Home: https://github.com/gorhill/uBlock
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2019-07-03 15:40:12 +02:00
|
|
|
µBlock.redirectEngine = (( ) => {
|
2015-11-23 13:52:50 +01:00
|
|
|
|
2015-11-26 23:56:30 +01:00
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2019-08-06 16:51:24 +02:00
|
|
|
// The resources referenced below are found in ./web_accessible_resources/
|
|
|
|
//
|
|
|
|
// The content of the resources which declare a `data` property will be loaded
|
|
|
|
// in memory, and converted to a suitable internal format depending on the
|
|
|
|
// type of the loaded data. The `data` property allows for manual injection
|
|
|
|
// through `+js(...)`, or for redirection to a data: URI when a redirection
|
|
|
|
// to a web accessible resource is not desirable.
|
|
|
|
|
2019-07-06 18:36:28 +02:00
|
|
|
const redirectableResources = new Map([
|
2019-07-03 15:40:12 +02:00
|
|
|
[ '1x1.gif', {
|
|
|
|
alias: '1x1-transparent.gif',
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'blob',
|
2019-07-03 15:40:12 +02:00
|
|
|
} ],
|
|
|
|
[ '2x2.png', {
|
|
|
|
alias: '2x2-transparent.png',
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'blob',
|
2019-07-03 15:40:12 +02:00
|
|
|
} ],
|
|
|
|
[ '3x2.png', {
|
|
|
|
alias: '3x2-transparent.png',
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'blob',
|
2019-07-03 15:40:12 +02:00
|
|
|
} ],
|
|
|
|
[ '32x32.png', {
|
|
|
|
alias: '32x32-transparent.png',
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'blob',
|
2019-07-03 15:40:12 +02:00
|
|
|
} ],
|
|
|
|
[ 'addthis_widget.js', {
|
|
|
|
alias: 'addthis.com/addthis_widget.js',
|
|
|
|
} ],
|
2019-08-13 14:16:21 +02:00
|
|
|
[ 'amazon_ads.js', {
|
|
|
|
alias: 'amazon-adsystem.com/aax2/amzn_ads.js',
|
|
|
|
} ],
|
2019-07-03 15:40:12 +02:00
|
|
|
[ 'ampproject_v0.js', {
|
|
|
|
alias: 'ampproject.org/v0.js',
|
|
|
|
} ],
|
|
|
|
[ 'chartbeat.js', {
|
|
|
|
alias: 'static.chartbeat.com/chartbeat.js',
|
|
|
|
} ],
|
|
|
|
[ 'disqus_embed.js', {
|
|
|
|
alias: 'disqus.com/embed.js',
|
|
|
|
} ],
|
|
|
|
[ 'disqus_forums_embed.js', {
|
|
|
|
alias: 'disqus.com/forums/*/embed.js',
|
|
|
|
} ],
|
|
|
|
[ 'doubleclick_instream_ad_status.js', {
|
|
|
|
alias: 'doubleclick.net/instream/ad_status.js',
|
|
|
|
} ],
|
2019-08-13 14:16:21 +02:00
|
|
|
[ 'empty', {
|
|
|
|
data: 'text', // Important!
|
|
|
|
} ],
|
2019-07-03 15:40:12 +02:00
|
|
|
[ 'google-analytics_analytics.js', {
|
|
|
|
alias: 'google-analytics.com/analytics.js',
|
|
|
|
} ],
|
|
|
|
[ 'google-analytics_cx_api.js', {
|
|
|
|
alias: 'google-analytics.com/cx/api.js',
|
|
|
|
} ],
|
|
|
|
[ 'google-analytics_ga.js', {
|
|
|
|
alias: 'google-analytics.com/ga.js',
|
|
|
|
} ],
|
|
|
|
[ 'google-analytics_inpage_linkid.js', {
|
|
|
|
alias: 'google-analytics.com/inpage_linkid.js',
|
|
|
|
} ],
|
|
|
|
[ 'googlesyndication_adsbygoogle.js', {
|
|
|
|
alias: 'googlesyndication.com/adsbygoogle.js',
|
|
|
|
} ],
|
|
|
|
[ 'googletagmanager_gtm.js', {
|
|
|
|
alias: 'googletagmanager.com/gtm.js',
|
|
|
|
} ],
|
|
|
|
[ 'googletagservices_gpt.js', {
|
|
|
|
alias: 'googletagservices.com/gpt.js',
|
|
|
|
} ],
|
|
|
|
[ 'hd-main.js', {
|
|
|
|
} ],
|
|
|
|
[ 'ligatus_angular-tag.js', {
|
|
|
|
alias: 'ligatus.com/*/angular-tag.js',
|
|
|
|
} ],
|
|
|
|
[ 'monkeybroker.js', {
|
|
|
|
alias: 'd3pkae9owd2lcf.cloudfront.net/mb105.js',
|
|
|
|
} ],
|
2019-07-04 01:26:09 +02:00
|
|
|
[ 'noeval.js', {
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'text',
|
2019-07-04 01:26:09 +02:00
|
|
|
} ],
|
2019-07-03 15:40:12 +02:00
|
|
|
[ 'noeval-silent.js', {
|
|
|
|
alias: 'silent-noeval.js',
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'text',
|
2019-07-03 15:40:12 +02:00
|
|
|
} ],
|
2019-07-09 17:04:12 +02:00
|
|
|
[ 'nobab.js', {
|
|
|
|
alias: 'bab-defuser.js',
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'text',
|
2019-07-09 17:04:12 +02:00
|
|
|
} ],
|
|
|
|
[ 'nofab.js', {
|
|
|
|
alias: 'fuckadblock.js-3.2.0',
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'text',
|
2019-07-09 17:04:12 +02:00
|
|
|
} ],
|
2019-07-03 15:40:12 +02:00
|
|
|
[ 'noop-0.1s.mp3', {
|
|
|
|
alias: 'noopmp3-0.1s',
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'blob',
|
2019-07-03 15:40:12 +02:00
|
|
|
} ],
|
|
|
|
[ 'noop-1s.mp4', {
|
|
|
|
alias: 'noopmp4-1s',
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'blob',
|
2019-07-03 15:40:12 +02:00
|
|
|
} ],
|
|
|
|
[ 'noop.html', {
|
|
|
|
alias: 'noopframe',
|
|
|
|
} ],
|
|
|
|
[ 'noop.js', {
|
|
|
|
alias: 'noopjs',
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'text',
|
2019-07-03 15:40:12 +02:00
|
|
|
} ],
|
|
|
|
[ 'noop.txt', {
|
|
|
|
alias: 'nooptext',
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'text',
|
2019-07-03 15:40:12 +02:00
|
|
|
} ],
|
|
|
|
[ 'outbrain-widget.js', {
|
|
|
|
alias: 'widgets.outbrain.com/outbrain.js',
|
|
|
|
} ],
|
|
|
|
[ 'popads.js', {
|
|
|
|
alias: 'popads.net.js',
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'text',
|
2019-07-03 15:40:12 +02:00
|
|
|
} ],
|
|
|
|
[ 'popads-dummy.js', {
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'text',
|
2019-07-03 15:40:12 +02:00
|
|
|
} ],
|
|
|
|
[ 'scorecardresearch_beacon.js', {
|
|
|
|
alias: 'scorecardresearch.com/beacon.js',
|
|
|
|
} ],
|
2019-07-04 20:08:56 +02:00
|
|
|
[ 'window.open-defuser.js', {
|
2019-08-06 16:51:24 +02:00
|
|
|
data: 'text',
|
2019-07-04 20:08:56 +02:00
|
|
|
} ],
|
2019-07-03 15:40:12 +02:00
|
|
|
]);
|
2018-02-16 15:07:20 +01:00
|
|
|
|
2019-07-08 14:56:36 +02:00
|
|
|
const extToMimeMap = new Map([
|
|
|
|
[ 'gif', 'image/gif' ],
|
|
|
|
[ 'html', 'text/html' ],
|
|
|
|
[ 'js', 'application/javascript' ],
|
|
|
|
[ 'mp3', 'audio/mp3' ],
|
|
|
|
[ 'mp4', 'video/mp4' ],
|
|
|
|
[ 'png', 'image/png' ],
|
|
|
|
[ 'txt', 'text/plain' ],
|
|
|
|
]);
|
|
|
|
|
2019-08-13 14:16:21 +02:00
|
|
|
const typeToMimeMap = new Map([
|
|
|
|
[ 'main_frame', 'text/html' ],
|
|
|
|
[ 'other', 'text/plain' ],
|
|
|
|
[ 'script', 'application/javascript' ],
|
|
|
|
[ 'stylesheet', 'text/css' ],
|
|
|
|
[ 'sub_frame', 'text/html' ],
|
|
|
|
[ 'xmlhttprequest', 'text/plain' ],
|
|
|
|
]);
|
|
|
|
|
2019-07-08 14:56:36 +02:00
|
|
|
const validMimes = new Set(extToMimeMap.values());
|
2018-02-15 23:25:38 +01:00
|
|
|
|
2019-07-06 18:36:28 +02:00
|
|
|
const mimeFromName = function(name) {
|
|
|
|
const match = /\.([^.]+)$/.exec(name);
|
|
|
|
if ( match !== null ) {
|
2019-07-08 14:56:36 +02:00
|
|
|
return extToMimeMap.get(match[1]);
|
2019-07-06 18:36:28 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-15 23:25:38 +01:00
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2019-08-13 14:16:21 +02:00
|
|
|
const RedirectEntry = class {
|
|
|
|
constructor() {
|
|
|
|
this.mime = '';
|
|
|
|
this.data = '';
|
|
|
|
this.warURL = undefined;
|
|
|
|
}
|
2015-11-26 23:56:30 +01:00
|
|
|
|
2019-08-13 14:16:21 +02:00
|
|
|
// Prevent redirection to web accessible resources when the request is
|
|
|
|
// of type 'xmlhttprequest', because XMLHttpRequest.responseURL would
|
|
|
|
// cause leakage of extension id. See:
|
|
|
|
// - https://stackoverflow.com/a/8056313
|
|
|
|
// - https://bugzilla.mozilla.org/show_bug.cgi?id=998076
|
2019-08-16 19:43:41 +02:00
|
|
|
// https://www.reddit.com/r/uBlockOrigin/comments/cpxm1v/
|
|
|
|
// User-supplied resources may already be base64 encoded.
|
2019-08-13 14:16:21 +02:00
|
|
|
|
|
|
|
toURL(fctxt, asDataURI = false) {
|
|
|
|
if (
|
|
|
|
this.warURL !== undefined &&
|
|
|
|
asDataURI !== true &&
|
|
|
|
fctxt instanceof Object &&
|
|
|
|
fctxt.type !== 'xmlhttprequest'
|
|
|
|
) {
|
|
|
|
return `${this.warURL}${vAPI.warSecret()}`;
|
|
|
|
}
|
|
|
|
if ( this.data === undefined ) { return; }
|
|
|
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/701
|
|
|
|
if ( this.data === '' ) {
|
|
|
|
const mime = typeToMimeMap.get(fctxt.type);
|
|
|
|
if ( mime === undefined ) { return; }
|
|
|
|
return `data:${mime},`;
|
|
|
|
}
|
|
|
|
if ( this.data.startsWith('data:') === false ) {
|
2019-08-16 19:43:41 +02:00
|
|
|
if ( this.mime.indexOf(';') === -1 ) {
|
|
|
|
this.data = `data:${this.mime};base64,${btoa(this.data)}`;
|
|
|
|
} else {
|
|
|
|
this.data = `data:${this.mime},${this.data}`;
|
|
|
|
}
|
2015-12-23 17:02:36 +01:00
|
|
|
}
|
2019-08-13 14:16:21 +02:00
|
|
|
return this.data;
|
2015-11-26 23:56:30 +01:00
|
|
|
}
|
2015-11-29 17:04:42 +01:00
|
|
|
|
2019-08-13 14:16:21 +02:00
|
|
|
toContent() {
|
|
|
|
if ( this.data.startsWith('data:') ) {
|
|
|
|
const pos = this.data.indexOf(',');
|
|
|
|
const base64 = this.data.endsWith(';base64', pos);
|
|
|
|
this.data = this.data.slice(pos + 1);
|
|
|
|
if ( base64 ) {
|
|
|
|
this.data = atob(this.data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this.data;
|
|
|
|
}
|
2015-11-29 17:04:42 +01:00
|
|
|
|
2019-08-13 14:16:21 +02:00
|
|
|
static fromContent(mime, content) {
|
|
|
|
const r = new RedirectEntry();
|
|
|
|
r.mime = mime;
|
|
|
|
r.data = content;
|
|
|
|
return r;
|
|
|
|
}
|
2015-11-29 17:04:42 +01:00
|
|
|
|
2019-08-13 14:16:21 +02:00
|
|
|
static fromSelfie(selfie) {
|
|
|
|
const r = new RedirectEntry();
|
|
|
|
r.mime = selfie.mime;
|
|
|
|
r.data = selfie.data;
|
|
|
|
r.warURL = selfie.warURL;
|
|
|
|
return r;
|
|
|
|
}
|
2015-11-26 23:56:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2015-11-23 13:52:50 +01:00
|
|
|
/******************************************************************************/
|
|
|
|
|
2018-10-31 23:34:54 +01:00
|
|
|
const RedirectEngine = function() {
|
2019-07-06 18:36:28 +02:00
|
|
|
this.aliases = new Map();
|
2016-10-10 15:01:05 +02:00
|
|
|
this.resources = new Map();
|
2015-11-23 13:52:50 +01:00
|
|
|
this.reset();
|
2016-01-07 23:30:56 +01:00
|
|
|
this.resourceNameRegister = '';
|
2015-11-23 13:52:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
RedirectEngine.prototype.reset = function() {
|
2016-10-10 15:01:05 +02:00
|
|
|
this.rules = new Map();
|
|
|
|
this.ruleSources = new Set();
|
|
|
|
this.ruleDestinations = new Set();
|
2019-08-24 19:48:50 +02:00
|
|
|
this.resetCache();
|
2017-12-21 23:05:25 +01:00
|
|
|
this.modifyTime = Date.now();
|
2015-11-23 13:52:50 +01:00
|
|
|
};
|
|
|
|
|
2019-08-24 19:48:50 +02:00
|
|
|
RedirectEngine.prototype.resetCache = function() {
|
|
|
|
this._src = '';
|
|
|
|
this._srcAll = [ '*' ];
|
|
|
|
this._des = '';
|
|
|
|
this._desAll = [ '*' ];
|
|
|
|
};
|
|
|
|
|
2015-11-23 13:52:50 +01:00
|
|
|
/******************************************************************************/
|
|
|
|
|
2015-11-24 01:18:25 +01:00
|
|
|
RedirectEngine.prototype.freeze = function() {
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2016-10-10 15:01:05 +02:00
|
|
|
RedirectEngine.prototype.toBroaderHostname = function(hostname) {
|
2019-07-06 18:36:28 +02:00
|
|
|
const pos = hostname.indexOf('.');
|
2016-10-10 15:01:05 +02:00
|
|
|
if ( pos !== -1 ) {
|
|
|
|
return hostname.slice(pos + 1);
|
|
|
|
}
|
|
|
|
return hostname !== '*' ? '*' : '';
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2019-08-13 14:16:21 +02:00
|
|
|
RedirectEngine.prototype.decomposeHostname = function(hn, dict, out) {
|
|
|
|
let i = 0;
|
2016-10-10 15:01:05 +02:00
|
|
|
for (;;) {
|
2019-08-13 14:16:21 +02:00
|
|
|
if ( dict.has(hn) ) {
|
|
|
|
out[i] = hn; i += 1;
|
2016-10-10 15:01:05 +02:00
|
|
|
}
|
2019-08-13 14:16:21 +02:00
|
|
|
hn = this.toBroaderHostname(hn);
|
|
|
|
if ( hn === '' ) { break; }
|
2015-11-23 13:52:50 +01:00
|
|
|
}
|
2019-08-13 14:16:21 +02:00
|
|
|
out.length = i;
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
RedirectEngine.prototype.lookup = function(fctxt) {
|
|
|
|
const src = fctxt.getDocHostname();
|
|
|
|
const des = fctxt.getHostname();
|
|
|
|
const type = fctxt.type;
|
|
|
|
if ( src !== this._src ) {
|
|
|
|
this._src = src;
|
|
|
|
this.decomposeHostname(src, this.ruleSources, this._srcAll);
|
|
|
|
}
|
2019-09-07 14:31:32 +02:00
|
|
|
if ( this._srcAll.length === 0 ) { return; }
|
2019-08-13 14:16:21 +02:00
|
|
|
if ( des !== this._des ) {
|
|
|
|
this._des = des;
|
|
|
|
this.decomposeHostname(des, this.ruleDestinations, this._desAll);
|
|
|
|
}
|
2019-09-07 14:31:32 +02:00
|
|
|
if ( this._desAll.length === 0 ) { return; }
|
2019-08-13 14:16:21 +02:00
|
|
|
const reqURL = fctxt.url;
|
|
|
|
for ( const src of this._srcAll ) {
|
|
|
|
for ( const des of this._desAll ) {
|
|
|
|
let entries = this.rules.get(`${src} ${des} ${type}`);
|
|
|
|
if ( entries !== undefined ) {
|
2019-08-06 16:51:24 +02:00
|
|
|
const rule = this.lookupRule(entries, reqURL);
|
2019-08-13 14:16:21 +02:00
|
|
|
if ( rule !== undefined ) { return rule; }
|
|
|
|
}
|
|
|
|
entries = this.rules.get(`${src} ${des} *`);
|
|
|
|
if ( entries !== undefined ) {
|
|
|
|
const rule = this.lookupRule(entries, reqURL);
|
|
|
|
if ( rule !== undefined ) { return rule; }
|
2015-11-23 13:52:50 +01:00
|
|
|
}
|
|
|
|
}
|
2016-10-10 15:01:05 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-08-06 16:51:24 +02:00
|
|
|
RedirectEngine.prototype.lookupRule = function(entries, reqURL) {
|
|
|
|
for ( const entry of entries ) {
|
2016-10-10 15:01:05 +02:00
|
|
|
if ( entry.pat instanceof RegExp === false ) {
|
|
|
|
entry.pat = new RegExp(entry.pat, 'i');
|
|
|
|
}
|
|
|
|
if ( entry.pat.test(reqURL) ) {
|
2019-08-06 16:51:24 +02:00
|
|
|
return entry;
|
2015-11-23 13:52:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2018-12-13 18:30:54 +01:00
|
|
|
RedirectEngine.prototype.toURL = function(fctxt) {
|
2019-08-06 16:51:24 +02:00
|
|
|
const rule = this.lookup(fctxt);
|
|
|
|
if ( rule === undefined ) { return; }
|
|
|
|
let token = this.resourceNameRegister = rule.tok;
|
|
|
|
const asDataURI = token.charCodeAt(0) === 0x25 /* '%' */;
|
|
|
|
if ( asDataURI ) {
|
|
|
|
token = token.slice(1);
|
|
|
|
}
|
2019-07-06 18:36:28 +02:00
|
|
|
const entry = this.resources.get(this.aliases.get(token) || token);
|
2015-11-26 23:56:30 +01:00
|
|
|
if ( entry !== undefined ) {
|
2019-08-06 16:51:24 +02:00
|
|
|
return entry.toURL(fctxt, asDataURI);
|
2015-11-26 23:56:30 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2015-11-24 01:18:25 +01:00
|
|
|
RedirectEngine.prototype.addRule = function(src, des, type, pattern, redirect) {
|
2016-10-10 15:01:05 +02:00
|
|
|
this.ruleSources.add(src);
|
|
|
|
this.ruleDestinations.add(des);
|
2019-07-06 18:36:28 +02:00
|
|
|
const key = `${src} ${des} ${type}`,
|
2016-10-10 15:01:05 +02:00
|
|
|
entries = this.rules.get(key);
|
|
|
|
if ( entries === undefined ) {
|
|
|
|
this.rules.set(key, [ { tok: redirect, pat: pattern } ]);
|
2017-12-21 23:05:25 +01:00
|
|
|
this.modifyTime = Date.now();
|
2016-10-10 15:01:05 +02:00
|
|
|
return;
|
2015-11-24 01:18:25 +01:00
|
|
|
}
|
2019-07-06 18:36:28 +02:00
|
|
|
let entry;
|
2016-10-10 15:01:05 +02:00
|
|
|
for ( var i = 0, n = entries.length; i < n; i++ ) {
|
|
|
|
entry = entries[i];
|
|
|
|
if ( redirect === entry.tok ) { break; }
|
2016-01-22 00:30:06 +01:00
|
|
|
}
|
2016-10-10 15:01:05 +02:00
|
|
|
if ( i === n ) {
|
|
|
|
entries.push({ tok: redirect, pat: pattern });
|
2016-01-22 00:30:06 +01:00
|
|
|
return;
|
|
|
|
}
|
2019-07-06 18:36:28 +02:00
|
|
|
let p = entry.pat;
|
2016-01-22 00:30:06 +01:00
|
|
|
if ( p instanceof RegExp ) {
|
|
|
|
p = p.source;
|
2015-11-24 01:18:25 +01:00
|
|
|
}
|
2016-01-22 00:30:06 +01:00
|
|
|
// Duplicate?
|
2019-07-06 18:36:28 +02:00
|
|
|
let pos = p.indexOf(pattern);
|
2016-01-22 00:30:06 +01:00
|
|
|
if ( pos !== -1 ) {
|
|
|
|
if ( pos === 0 || p.charAt(pos - 1) === '|' ) {
|
|
|
|
pos += pattern.length;
|
2016-10-10 15:01:05 +02:00
|
|
|
if ( pos === p.length || p.charAt(pos) === '|' ) { return; }
|
2016-01-22 00:30:06 +01:00
|
|
|
}
|
|
|
|
}
|
2016-10-10 15:01:05 +02:00
|
|
|
entry.pat = p + '|' + pattern;
|
2015-11-24 01:18:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
RedirectEngine.prototype.fromCompiledRule = function(line) {
|
2019-05-14 02:19:10 +02:00
|
|
|
const fields = line.split('\t');
|
|
|
|
if ( fields.length !== 5 ) { return; }
|
2015-11-24 01:18:25 +01:00
|
|
|
this.addRule(fields[0], fields[1], fields[2], fields[3], fields[4]);
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
RedirectEngine.prototype.compileRuleFromStaticFilter = function(line) {
|
2018-12-17 13:46:04 +01:00
|
|
|
const matches = this.reFilterParser.exec(line);
|
|
|
|
if ( matches === null || matches.length !== 4 ) { return; }
|
|
|
|
|
2019-05-14 02:19:10 +02:00
|
|
|
const des = matches[1] || '';
|
|
|
|
|
|
|
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/572
|
|
|
|
// Extract best possible hostname.
|
|
|
|
let deshn = des;
|
2019-05-14 15:29:45 +02:00
|
|
|
let pos = deshn.lastIndexOf('*');
|
2019-05-14 02:19:10 +02:00
|
|
|
if ( pos !== -1 ) {
|
|
|
|
deshn = deshn.slice(pos + 1);
|
2019-05-14 15:29:45 +02:00
|
|
|
pos = deshn.indexOf('.');
|
|
|
|
if ( pos !== -1 ) {
|
|
|
|
deshn = deshn.slice(pos + 1);
|
|
|
|
} else {
|
|
|
|
deshn = '';
|
2019-05-14 02:19:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-03 16:18:47 +02:00
|
|
|
const path = matches[2] || '';
|
|
|
|
let pattern =
|
2019-05-14 02:19:10 +02:00
|
|
|
des
|
2019-05-14 12:52:13 +02:00
|
|
|
.replace(/\*/g, '[\\w.%-]*')
|
2019-05-14 02:19:10 +02:00
|
|
|
.replace(/\./g, '\\.') +
|
2019-08-03 16:18:47 +02:00
|
|
|
path
|
2019-05-14 02:19:10 +02:00
|
|
|
.replace(/[.+?{}()|[\]\/\\]/g, '\\$&')
|
|
|
|
.replace(/\^/g, '[^\\w.%-]')
|
|
|
|
.replace(/\*/g, '.*?');
|
2019-08-03 16:18:47 +02:00
|
|
|
if ( pattern === '' ) {
|
|
|
|
pattern = '^';
|
|
|
|
}
|
2019-05-14 02:19:10 +02:00
|
|
|
|
2018-12-17 13:46:04 +01:00
|
|
|
let type,
|
2016-10-26 14:59:15 +02:00
|
|
|
redirect = '',
|
2019-05-14 02:19:10 +02:00
|
|
|
srchns = [];
|
2018-12-17 13:46:04 +01:00
|
|
|
for ( const option of matches[3].split(',') ) {
|
2015-12-15 16:40:40 +01:00
|
|
|
if ( option.startsWith('redirect=') ) {
|
2015-11-24 01:18:25 +01:00
|
|
|
redirect = option.slice(9);
|
|
|
|
continue;
|
|
|
|
}
|
2019-08-03 16:18:47 +02:00
|
|
|
if ( option.startsWith('redirect-rule=') ) {
|
|
|
|
redirect = option.slice(14);
|
|
|
|
continue;
|
|
|
|
}
|
2019-08-13 14:16:21 +02:00
|
|
|
if ( option === 'empty' ) {
|
|
|
|
redirect = 'empty';
|
|
|
|
continue;
|
|
|
|
}
|
2019-08-13 18:30:11 +02:00
|
|
|
if ( option === 'mp4' ) {
|
|
|
|
redirect = 'noopmp4-1s';
|
|
|
|
continue;
|
|
|
|
}
|
2015-12-15 16:40:40 +01:00
|
|
|
if ( option.startsWith('domain=') ) {
|
2019-05-14 02:19:10 +02:00
|
|
|
srchns = option.slice(7).split('|');
|
2015-11-24 01:18:25 +01:00
|
|
|
continue;
|
|
|
|
}
|
2019-05-14 15:29:45 +02:00
|
|
|
if ( (option === 'first-party' || option === '1p') && deshn !== '' ) {
|
2019-05-14 02:19:10 +02:00
|
|
|
srchns.push(µBlock.URI.domainFromHostname(deshn) || deshn);
|
2015-12-16 03:34:36 +01:00
|
|
|
continue;
|
|
|
|
}
|
2015-11-25 16:05:23 +01:00
|
|
|
// One and only one type must be specified.
|
2018-12-17 13:46:04 +01:00
|
|
|
if ( this.supportedTypes.has(option) ) {
|
|
|
|
if ( type !== undefined ) { return; }
|
|
|
|
type = this.supportedTypes.get(option);
|
2015-11-24 01:18:25 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-24 05:34:03 +01:00
|
|
|
// Need a resource token.
|
2018-12-17 13:46:04 +01:00
|
|
|
if ( redirect === '' ) { return; }
|
2015-11-24 05:34:03 +01:00
|
|
|
|
2015-11-25 16:05:23 +01:00
|
|
|
// Need one single type -- not negated.
|
2019-08-13 14:16:21 +02:00
|
|
|
if ( type === undefined ) {
|
2019-08-13 18:30:11 +02:00
|
|
|
if ( redirect === 'empty' ) {
|
|
|
|
type = '*';
|
|
|
|
} else if ( redirect === 'noopmp4-1s' ) {
|
|
|
|
type = 'media';
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2019-08-13 14:16:21 +02:00
|
|
|
}
|
2015-11-24 01:18:25 +01:00
|
|
|
|
2019-05-14 02:19:10 +02:00
|
|
|
if ( deshn === '' ) {
|
|
|
|
deshn = '*';
|
2015-11-24 01:18:25 +01:00
|
|
|
}
|
|
|
|
|
2019-05-14 02:19:10 +02:00
|
|
|
if ( srchns.length === 0 ) {
|
|
|
|
srchns.push('*');
|
2015-11-24 01:18:25 +01:00
|
|
|
}
|
|
|
|
|
2018-12-17 13:46:04 +01:00
|
|
|
const out = [];
|
2019-05-14 02:19:10 +02:00
|
|
|
for ( const srchn of srchns ) {
|
|
|
|
if ( srchn === '' ) { continue; }
|
|
|
|
if ( srchn.startsWith('~') ) { continue; }
|
2019-07-06 18:36:28 +02:00
|
|
|
out.push(`${srchn}\t${deshn}\t${type}\t${pattern}\t${redirect}`);
|
2015-11-24 01:18:25 +01:00
|
|
|
}
|
|
|
|
|
2019-08-03 16:18:47 +02:00
|
|
|
if ( out.length === 0 ) { return; }
|
|
|
|
|
2015-11-24 01:18:25 +01:00
|
|
|
return out;
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2019-08-03 16:18:47 +02:00
|
|
|
RedirectEngine.prototype.reFilterParser = /^(?:\|\|([^\/:?#^]+)|\*)([^$]+)?\$([^$]+)$/;
|
2015-11-24 01:18:25 +01:00
|
|
|
|
2018-12-17 13:46:04 +01:00
|
|
|
RedirectEngine.prototype.supportedTypes = new Map([
|
|
|
|
[ 'css', 'stylesheet' ],
|
|
|
|
[ 'font', 'font' ],
|
|
|
|
[ 'image', 'image' ],
|
|
|
|
[ 'media', 'media' ],
|
|
|
|
[ 'object', 'object' ],
|
|
|
|
[ 'script', 'script' ],
|
|
|
|
[ 'stylesheet', 'stylesheet' ],
|
|
|
|
[ 'frame', 'sub_frame' ],
|
|
|
|
[ 'subdocument', 'sub_frame' ],
|
|
|
|
[ 'xhr', 'xmlhttprequest' ],
|
|
|
|
[ 'xmlhttprequest', 'xmlhttprequest' ],
|
|
|
|
]);
|
2015-11-24 01:18:25 +01:00
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2019-02-14 19:33:55 +01:00
|
|
|
RedirectEngine.prototype.toSelfie = function(path) {
|
2016-10-10 15:01:05 +02:00
|
|
|
// Because rules may contains RegExp instances, we need to manually
|
|
|
|
// convert it to a serializable format. The serialized format must be
|
|
|
|
// suitable to be used as an argument to the Map() constructor.
|
2019-02-14 19:33:55 +01:00
|
|
|
const rules = [];
|
|
|
|
for ( const item of this.rules ) {
|
|
|
|
const rule = [ item[0], [] ];
|
|
|
|
const entries = item[1];
|
|
|
|
let i = entries.length;
|
2016-10-10 15:01:05 +02:00
|
|
|
while ( i-- ) {
|
2019-02-14 19:33:55 +01:00
|
|
|
const entry = entries[i];
|
2016-10-10 15:01:05 +02:00
|
|
|
rule[1].push({
|
|
|
|
tok: entry.tok,
|
|
|
|
pat: entry.pat instanceof RegExp ? entry.pat.source : entry.pat
|
|
|
|
});
|
2015-11-29 23:06:58 +01:00
|
|
|
}
|
2016-10-10 15:01:05 +02:00
|
|
|
rules.push(rule);
|
2015-11-29 23:06:58 +01:00
|
|
|
}
|
2019-02-14 19:33:55 +01:00
|
|
|
return µBlock.assets.put(
|
|
|
|
`${path}/main`,
|
|
|
|
JSON.stringify({
|
|
|
|
rules: rules,
|
|
|
|
ruleSources: Array.from(this.ruleSources),
|
|
|
|
ruleDestinations: Array.from(this.ruleDestinations)
|
|
|
|
})
|
|
|
|
);
|
2015-11-29 17:04:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2019-09-15 13:58:28 +02:00
|
|
|
RedirectEngine.prototype.fromSelfie = async function(path) {
|
|
|
|
const result = await µBlock.assets.get(`${path}/main`);
|
|
|
|
let selfie;
|
|
|
|
try {
|
|
|
|
selfie = JSON.parse(result.content);
|
|
|
|
} catch (ex) {
|
|
|
|
}
|
|
|
|
if ( selfie instanceof Object === false ) { return false; }
|
|
|
|
this.rules = new Map(selfie.rules);
|
|
|
|
this.ruleSources = new Set(selfie.ruleSources);
|
|
|
|
this.ruleDestinations = new Set(selfie.ruleDestinations);
|
|
|
|
this.resetCache();
|
|
|
|
this.modifyTime = Date.now();
|
|
|
|
return true;
|
2015-11-29 17:04:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2015-12-23 17:02:36 +01:00
|
|
|
RedirectEngine.prototype.resourceContentFromName = function(name, mime) {
|
2019-07-06 18:36:28 +02:00
|
|
|
const entry = this.resources.get(this.aliases.get(name) || name);
|
|
|
|
if ( entry === undefined ) { return; }
|
2016-10-10 15:01:05 +02:00
|
|
|
if ( mime === undefined || entry.mime.startsWith(mime) ) {
|
2015-12-23 17:02:36 +01:00
|
|
|
return entry.toContent();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2015-11-24 01:18:25 +01:00
|
|
|
// TODO: combine same key-redirect pairs into a single regex.
|
|
|
|
|
2018-10-31 23:34:54 +01:00
|
|
|
// https://github.com/uBlockOrigin/uAssets/commit/deefe875551197d655f79cb540e62dfc17c95f42
|
|
|
|
// Consider 'none' a reserved keyword, to be used to disable redirection.
|
|
|
|
|
2019-07-06 18:36:28 +02:00
|
|
|
RedirectEngine.prototype.resourcesFromString = function(text) {
|
|
|
|
const lineIter = new µBlock.LineIterator(removeTopCommentBlock(text));
|
2019-07-03 15:40:12 +02:00
|
|
|
const reNonEmptyLine = /\S/;
|
2019-07-06 18:36:28 +02:00
|
|
|
let fields, encoded, details;
|
2015-11-23 13:52:50 +01:00
|
|
|
|
2017-01-18 19:17:47 +01:00
|
|
|
while ( lineIter.eot() === false ) {
|
2018-10-31 23:34:54 +01:00
|
|
|
let line = lineIter.next();
|
2017-01-18 19:17:47 +01:00
|
|
|
if ( line.startsWith('#') ) { continue; }
|
2019-07-06 18:36:28 +02:00
|
|
|
if ( line.startsWith('// ') ) { continue; }
|
2015-11-23 13:52:50 +01:00
|
|
|
|
2015-11-24 19:21:14 +01:00
|
|
|
if ( fields === undefined ) {
|
2019-07-08 14:56:36 +02:00
|
|
|
if ( line === '' ) { continue; }
|
|
|
|
// Modern parser
|
2019-07-06 18:36:28 +02:00
|
|
|
if ( line.startsWith('/// ') ) {
|
|
|
|
const name = line.slice(4).trim();
|
|
|
|
fields = [ name, mimeFromName(name) ];
|
2019-07-08 14:56:36 +02:00
|
|
|
continue;
|
2019-07-06 18:36:28 +02:00
|
|
|
}
|
2019-07-08 14:56:36 +02:00
|
|
|
// Legacy parser
|
|
|
|
const head = line.trim().split(/\s+/);
|
|
|
|
if ( head.length !== 2 ) { continue; }
|
|
|
|
if ( head[0] === 'none' ) { continue; }
|
|
|
|
let pos = head[1].indexOf(';');
|
|
|
|
if ( pos === -1 ) { pos = head[1].length; }
|
|
|
|
if ( validMimes.has(head[1].slice(0, pos)) === false ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
encoded = head[1].indexOf(';') !== -1;
|
|
|
|
fields = head;
|
2019-07-06 18:36:28 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( line.startsWith('/// ') ) {
|
|
|
|
if ( details === undefined ) {
|
|
|
|
details = {};
|
|
|
|
}
|
|
|
|
const [ prop, value ] = line.slice(4).trim().split(/\s+/);
|
|
|
|
if ( value !== undefined ) {
|
|
|
|
details[prop] = value;
|
|
|
|
}
|
2015-11-23 13:52:50 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-11-26 01:38:05 +01:00
|
|
|
if ( reNonEmptyLine.test(line) ) {
|
|
|
|
fields.push(encoded ? line.trim() : line);
|
2015-11-23 13:52:50 +01:00
|
|
|
continue;
|
|
|
|
}
|
2015-11-24 05:34:03 +01:00
|
|
|
|
2019-07-08 14:56:36 +02:00
|
|
|
const name = this.aliases.get(fields[0]) || fields[0];
|
2019-07-06 18:36:28 +02:00
|
|
|
const mime = fields[1];
|
|
|
|
const content = µBlock.orphanizeString(
|
|
|
|
fields.slice(2).join(encoded ? '' : '\n')
|
|
|
|
);
|
|
|
|
|
2015-11-24 19:21:14 +01:00
|
|
|
// No more data, add the resource.
|
2019-07-06 18:36:28 +02:00
|
|
|
this.resources.set(
|
|
|
|
name,
|
|
|
|
RedirectEntry.fromContent(mime, content)
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( details instanceof Object && details.alias ) {
|
|
|
|
this.aliases.set(details.alias, name);
|
2019-07-03 15:40:12 +02:00
|
|
|
}
|
2015-11-24 19:21:14 +01:00
|
|
|
|
|
|
|
fields = undefined;
|
2019-07-06 18:36:28 +02:00
|
|
|
details = undefined;
|
2015-11-24 19:21:14 +01:00
|
|
|
}
|
2015-11-24 05:34:03 +01:00
|
|
|
|
2015-11-24 19:21:14 +01:00
|
|
|
// Process pending resource data.
|
|
|
|
if ( fields !== undefined ) {
|
2019-07-06 18:36:28 +02:00
|
|
|
const name = fields[0];
|
|
|
|
const mime = fields[1];
|
|
|
|
const content = µBlock.orphanizeString(
|
|
|
|
fields.slice(2).join(encoded ? '' : '\n')
|
|
|
|
);
|
2018-10-31 23:34:54 +01:00
|
|
|
this.resources.set(
|
2019-07-06 18:36:28 +02:00
|
|
|
name,
|
|
|
|
RedirectEntry.fromContent(mime, content)
|
2018-10-31 23:34:54 +01:00
|
|
|
);
|
2019-07-06 18:36:28 +02:00
|
|
|
if ( details instanceof Object && details.alias ) {
|
|
|
|
this.aliases.set(details.alias, name);
|
|
|
|
}
|
2015-11-23 13:52:50 +01:00
|
|
|
}
|
2018-02-16 15:07:20 +01:00
|
|
|
|
2018-03-19 15:25:03 +01:00
|
|
|
this.modifyTime = Date.now();
|
2015-11-23 13:52:50 +01:00
|
|
|
};
|
|
|
|
|
2019-07-06 18:36:28 +02:00
|
|
|
const removeTopCommentBlock = function(text) {
|
|
|
|
return text.replace(/^\/\*[\S\s]+?\n\*\/\s*/, '');
|
|
|
|
};
|
|
|
|
|
2018-02-15 23:25:38 +01:00
|
|
|
/******************************************************************************/
|
|
|
|
|
2019-07-03 15:40:12 +02:00
|
|
|
RedirectEngine.prototype.loadBuiltinResources = function() {
|
2019-07-06 18:36:28 +02:00
|
|
|
// TODO: remove once usage of uBO 1.20.4 is widespread.
|
|
|
|
µBlock.assets.remove('ublock-resources');
|
|
|
|
|
2019-08-13 14:16:21 +02:00
|
|
|
this.resources = new Map();
|
|
|
|
this.aliases = new Map();
|
|
|
|
|
2019-08-06 16:51:24 +02:00
|
|
|
const fetches = [
|
|
|
|
µBlock.assets.fetchText(
|
|
|
|
'/assets/resources/scriptlets.js'
|
|
|
|
).then(result => {
|
|
|
|
const content = result.content;
|
|
|
|
if ( typeof content === 'string' && content.length !== 0 ) {
|
|
|
|
this.resourcesFromString(content);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
];
|
|
|
|
|
|
|
|
const store = (name, data = undefined) => {
|
|
|
|
const details = redirectableResources.get(name);
|
2019-07-03 15:40:12 +02:00
|
|
|
const entry = RedirectEntry.fromSelfie({
|
|
|
|
mime: mimeFromName(name),
|
2019-08-06 16:51:24 +02:00
|
|
|
data,
|
2019-07-03 15:40:12 +02:00
|
|
|
warURL: vAPI.getURL(`/web_accessible_resources/${name}`),
|
|
|
|
});
|
|
|
|
this.resources.set(name, entry);
|
|
|
|
if ( details.alias !== undefined ) {
|
2019-07-06 18:36:28 +02:00
|
|
|
this.aliases.set(details.alias, name);
|
2019-07-03 15:40:12 +02:00
|
|
|
}
|
2019-08-06 16:51:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const processBlob = (name, blob) => {
|
|
|
|
return new Promise(resolve => {
|
|
|
|
const reader = new FileReader();
|
|
|
|
reader.onload = ( ) => {
|
|
|
|
store(name, reader.result);
|
|
|
|
resolve();
|
|
|
|
};
|
|
|
|
reader.readAsDataURL(blob);
|
|
|
|
});
|
|
|
|
};
|
2019-07-06 18:36:28 +02:00
|
|
|
|
2019-08-06 16:51:24 +02:00
|
|
|
const processText = (name, text) => {
|
|
|
|
store(name, removeTopCommentBlock(text));
|
|
|
|
};
|
|
|
|
|
|
|
|
const process = result => {
|
|
|
|
const match = /^\/web_accessible_resources\/([^?]+)/.exec(result.url);
|
|
|
|
if ( match === null ) { return; }
|
|
|
|
const name = match[1];
|
|
|
|
return result.content instanceof Blob
|
|
|
|
? processBlob(name, result.content)
|
|
|
|
: processText(name, result.content);
|
|
|
|
};
|
|
|
|
|
|
|
|
for ( const [ name, details ] of redirectableResources ) {
|
|
|
|
if ( typeof details.data !== 'string' ) {
|
|
|
|
store(name);
|
|
|
|
continue;
|
2019-07-03 15:40:12 +02:00
|
|
|
}
|
2019-08-06 16:51:24 +02:00
|
|
|
fetches.push(
|
|
|
|
µBlock.assets.fetch(
|
|
|
|
`/web_accessible_resources/${name}${vAPI.warSecret()}`,
|
|
|
|
{ responseType: details.data }
|
|
|
|
).then(
|
|
|
|
result => process(result)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Promise.all(fetches);
|
2019-07-03 15:40:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2019-07-09 17:04:12 +02:00
|
|
|
const resourcesSelfieVersion = 5;
|
2018-02-15 23:25:38 +01:00
|
|
|
|
|
|
|
RedirectEngine.prototype.selfieFromResources = function() {
|
2019-02-14 19:33:55 +01:00
|
|
|
µBlock.assets.put(
|
|
|
|
'compiled/redirectEngine/resources',
|
|
|
|
JSON.stringify({
|
|
|
|
version: resourcesSelfieVersion,
|
2019-07-06 18:36:28 +02:00
|
|
|
aliases: Array.from(this.aliases),
|
|
|
|
resources: Array.from(this.resources),
|
2019-02-14 19:33:55 +01:00
|
|
|
})
|
|
|
|
);
|
2018-02-15 23:25:38 +01:00
|
|
|
};
|
|
|
|
|
2019-09-15 13:58:28 +02:00
|
|
|
RedirectEngine.prototype.resourcesFromSelfie = async function() {
|
|
|
|
const result = await µBlock.assets.get('compiled/redirectEngine/resources');
|
|
|
|
let selfie;
|
|
|
|
try {
|
|
|
|
selfie = JSON.parse(result.content);
|
|
|
|
} catch(ex) {
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
selfie instanceof Object === false ||
|
|
|
|
selfie.version !== resourcesSelfieVersion ||
|
|
|
|
Array.isArray(selfie.resources) === false
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
this.aliases = new Map(selfie.aliases);
|
|
|
|
this.resources = new Map();
|
|
|
|
for ( const [ token, entry ] of selfie.resources ) {
|
|
|
|
this.resources.set(token, RedirectEntry.fromSelfie(entry));
|
|
|
|
}
|
|
|
|
return true;
|
2018-02-15 23:25:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
RedirectEngine.prototype.invalidateResourcesSelfie = function() {
|
2019-02-14 19:33:55 +01:00
|
|
|
µBlock.assets.remove('compiled/redirectEngine/resources');
|
|
|
|
|
|
|
|
// TODO: obsolete, remove eventually
|
2018-08-11 16:39:43 +02:00
|
|
|
µBlock.cacheStorage.remove('resourcesSelfie');
|
2018-02-15 23:25:38 +01:00
|
|
|
};
|
|
|
|
|
2015-11-26 23:56:30 +01:00
|
|
|
/******************************************************************************/
|
2015-11-23 13:52:50 +01:00
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
return new RedirectEngine();
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
})();
|