mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-06-03 10:54:55 +12:00
fix #940
This commit is contained in:
parent
55b9f1c645
commit
335709bc50
|
@ -103,6 +103,7 @@ var requestStatsFactory = function() {
|
||||||
var rawSettingsDefault = {
|
var rawSettingsDefault = {
|
||||||
contributorMode: false,
|
contributorMode: false,
|
||||||
disableCSPReportInjection: false,
|
disableCSPReportInjection: false,
|
||||||
|
enforceEscapedFragment: true,
|
||||||
placeholderBackground:
|
placeholderBackground:
|
||||||
[
|
[
|
||||||
'url("data:image/png;base64,',
|
'url("data:image/png;base64,',
|
||||||
|
|
|
@ -53,7 +53,10 @@ var onBeforeRootFrameRequestHandler = function(details) {
|
||||||
|
|
||||||
// Not blocked
|
// Not blocked
|
||||||
if ( !block ) {
|
if ( !block ) {
|
||||||
// rhill 2013-11-07: Senseless to do this for behind-the-scene requests.
|
let redirectURL = maybeRedirectRootFrame(requestHostname, requestURL);
|
||||||
|
if ( redirectURL !== requestURL ) {
|
||||||
|
return { redirectUrl: redirectURL };
|
||||||
|
}
|
||||||
µm.cookieHunter.recordPageCookies(pageStore);
|
µm.cookieHunter.recordPageCookies(pageStore);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +75,27 @@ var onBeforeRootFrameRequestHandler = function(details) {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
// https://twitter.com/thatcks/status/958776519765225473
|
||||||
|
|
||||||
|
var maybeRedirectRootFrame = function(hostname, url) {
|
||||||
|
let µm = µMatrix;
|
||||||
|
if ( µm.rawSettings.enforceEscapedFragment !== true ) { return url; }
|
||||||
|
let block1pScripts = µm.mustBlock(hostname, hostname, 'script');
|
||||||
|
let reEscapedFragment = /[?&]_escaped_fragment_=/;
|
||||||
|
if ( reEscapedFragment.test(url) ) {
|
||||||
|
return block1pScripts ? url : url.replace(reEscapedFragment, '#!') ;
|
||||||
|
}
|
||||||
|
if ( block1pScripts === false ) { return url; }
|
||||||
|
let pos = url.indexOf('#!');
|
||||||
|
if ( pos === -1 ) { return url; }
|
||||||
|
let separator = url.lastIndexOf('?', pos) === -1 ? '?' : '&';
|
||||||
|
return url.slice(0, pos) +
|
||||||
|
separator + '_escaped_fragment_=' +
|
||||||
|
url.slice(pos + 2);
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
// Intercept and filter web requests according to white and black lists.
|
// Intercept and filter web requests according to white and black lists.
|
||||||
|
|
||||||
var onBeforeRequestHandler = function(details) {
|
var onBeforeRequestHandler = function(details) {
|
||||||
|
|
Loading…
Reference in a new issue