mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
this fixes #870
This commit is contained in:
parent
bd229db64e
commit
95d0ffafb7
@ -1,7 +1,7 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
µBlock - a browser extension to block requests.
|
uBlock Origin - a browser extension to block requests.
|
||||||
Copyright (C) 2014 The µBlock authors
|
Copyright (C) 2014-2016 The uBlock Origin authors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -788,6 +788,11 @@ vAPI.net.registerListeners = function() {
|
|||||||
var µb = µBlock;
|
var µb = µBlock;
|
||||||
var µburi = µb.URI;
|
var µburi = µb.URI;
|
||||||
|
|
||||||
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=410382
|
||||||
|
// Between Chromium 38-48, plug-ins' network requests were reported as
|
||||||
|
// type "other" instead of "object".
|
||||||
|
var is_v38_48 = /\bChrom[a-z]+\/(?:3[89]|4[0-8])\.[\d.]+\b/.test(navigator.userAgent);
|
||||||
|
|
||||||
// Chromium-based browsers understand only these network request types.
|
// Chromium-based browsers understand only these network request types.
|
||||||
var validTypes = {
|
var validTypes = {
|
||||||
'main_frame': true,
|
'main_frame': true,
|
||||||
@ -836,6 +841,14 @@ vAPI.net.registerListeners = function() {
|
|||||||
var normalizeRequestDetails = function(details) {
|
var normalizeRequestDetails = function(details) {
|
||||||
details.tabId = details.tabId.toString();
|
details.tabId = details.tabId.toString();
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/1493
|
||||||
|
// Chromium 49+ support a new request type: `ping`, which is fired as
|
||||||
|
// a result of using `navigator.sendBeacon`.
|
||||||
|
if ( details.type === 'ping' ) {
|
||||||
|
details.type = 'beacon';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// The rest of the function code is to normalize type
|
// The rest of the function code is to normalize type
|
||||||
if ( details.type !== 'other' ) {
|
if ( details.type !== 'other' ) {
|
||||||
return;
|
return;
|
||||||
@ -885,7 +898,9 @@ vAPI.net.registerListeners = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// https://code.google.com/p/chromium/issues/detail?id=410382
|
// https://code.google.com/p/chromium/issues/detail?id=410382
|
||||||
|
if ( is_v38_48 ) {
|
||||||
details.type = 'object';
|
details.type = 'object';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var onBeforeRequestClient = this.onBeforeRequest.callback;
|
var onBeforeRequestClient = this.onBeforeRequest.callback;
|
||||||
|
@ -807,6 +807,10 @@ vAPI.tabs.registerListeners();
|
|||||||
return this.pageStores[tabId] || null;
|
return this.pageStores[tabId] || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
µb.mustPageStoreFromTabId = function(tabId) {
|
||||||
|
return this.pageStores[tabId] || this.pageStores[vAPI.noTabId];
|
||||||
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// Permanent page store for behind-the-scene requests. Must never be removed.
|
// Permanent page store for behind-the-scene requests. Must never be removed.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
uBlock - a browser extension to block requests.
|
uBlock Origin - a browser extension to block requests.
|
||||||
Copyright (C) 2014-2015 Raymond Hill
|
Copyright (C) 2014-2016 Raymond Hill
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -47,6 +47,12 @@ var onBeforeRequest = function(details) {
|
|||||||
return onBeforeRootFrameRequest(details);
|
return onBeforeRootFrameRequest(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/870
|
||||||
|
// This work for Chromium 49+.
|
||||||
|
if ( requestType === 'beacon' ) {
|
||||||
|
return onBeforeBeacon(details);
|
||||||
|
}
|
||||||
|
|
||||||
// Special treatment: behind-the-scene requests
|
// Special treatment: behind-the-scene requests
|
||||||
var tabId = details.tabId;
|
var tabId = details.tabId;
|
||||||
if ( vAPI.isBehindTheSceneTabId(tabId) ) {
|
if ( vAPI.isBehindTheSceneTabId(tabId) ) {
|
||||||
@ -273,6 +279,40 @@ var toBlockDocResult = function(url, hostname, result) {
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/870
|
||||||
|
// Finally, Chromium 49+ gained the ability to report network request of type
|
||||||
|
// `beacon`, so now we can block them according to the state of the
|
||||||
|
// "Disable hyperlink auditing/beacon" setting.
|
||||||
|
|
||||||
|
var onBeforeBeacon = function(details) {
|
||||||
|
var µb = µBlock;
|
||||||
|
var tabId = details.tabId;
|
||||||
|
var pageStore = µb.mustPageStoreFromTabId(tabId);
|
||||||
|
var context = pageStore.createContextFromPage();
|
||||||
|
context.requestURL = details.url;
|
||||||
|
context.requestHostname = µb.URI.hostnameFromURI(details.url);
|
||||||
|
context.requestType = details.type;
|
||||||
|
// "g" in "gb:" stands for "global setting"
|
||||||
|
var result = µb.userSettings.hyperlinkAuditingDisabled ? 'gb:' : '';
|
||||||
|
pageStore.logRequest(context, result);
|
||||||
|
if ( µb.logger.isEnabled() ) {
|
||||||
|
µb.logger.writeOne(
|
||||||
|
tabId,
|
||||||
|
'net',
|
||||||
|
result,
|
||||||
|
details.type,
|
||||||
|
details.url,
|
||||||
|
context.rootHostname,
|
||||||
|
context.rootHostname
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ( result !== '' ) {
|
||||||
|
return { cancel: true };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
// Intercept and filter behind-the-scene requests.
|
// Intercept and filter behind-the-scene requests.
|
||||||
|
|
||||||
var onBeforeBehindTheSceneRequest = function(details) {
|
var onBeforeBehindTheSceneRequest = function(details) {
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<li><input id="advanced-user-enabled" type="checkbox" data-setting-name="advancedUserEnabled" data-setting-type="bool"><label data-i18n="settingsAdvancedUserPrompt" for="advanced-user-enabled"></label>
|
<li><input id="advanced-user-enabled" type="checkbox" data-setting-name="advancedUserEnabled" data-setting-type="bool"><label data-i18n="settingsAdvancedUserPrompt" for="advanced-user-enabled"></label>
|
||||||
<li class="subgroup"><span data-i18n="3pGroupPrivacy"></span><ul>
|
<li class="subgroup"><span data-i18n="3pGroupPrivacy"></span><ul>
|
||||||
<li><input id="prefetching-disabled" type="checkbox" data-setting-name="prefetchingDisabled" data-setting-type="bool"><label data-i18n="settingsPrefetchingDisabledPrompt" for="prefetching-disabled"></label> <a class="fa info" href="https://wikipedia.org/wiki/Link_prefetching#Issues_and_criticisms" target="_blank"></a>
|
<li><input id="prefetching-disabled" type="checkbox" data-setting-name="prefetchingDisabled" data-setting-type="bool"><label data-i18n="settingsPrefetchingDisabledPrompt" for="prefetching-disabled"></label> <a class="fa info" href="https://wikipedia.org/wiki/Link_prefetching#Issues_and_criticisms" target="_blank"></a>
|
||||||
<li><input id="hyperlink-auditing-disabled" type="checkbox" data-setting-name="hyperlinkAuditingDisabled" data-setting-type="bool"><label data-i18n="settingsHyperlinkAuditingDisabledPrompt" for="hyperlink-auditing-disabled"></label> <a class="fa info" href="http://www.wilderssecurity.com/threads/hyperlink-auditing-aka-a-ping-and-beacon-aka-navigator-sendbeacon.364904/" target="_blank"></a>
|
<li><input id="hyperlink-auditing-disabled" type="checkbox" data-setting-name="hyperlinkAuditingDisabled" data-setting-type="bool"><label data-i18n="settingsHyperlinkAuditingDisabledPrompt" for="hyperlink-auditing-disabled"></label> <a class="fa info important" href="https://github.com/gorhill/uBlock/wiki/Disable-hyperlink-auditing-beacon" target="_blank"></a>
|
||||||
<li><input id="webrtc-ipaddress-hidden" type="checkbox" data-setting-name="webrtcIPAddressHidden" data-setting-type="bool"><label data-i18n="settingsWebRTCIPAddressHiddenPrompt" for="webrtc-ipaddress-hidden"></label> <a class="fa info important" href="https://github.com/gorhill/uBlock/wiki/Prevent-WebRTC-from-leaking-local-IP-address" target="_blank"></a>
|
<li><input id="webrtc-ipaddress-hidden" type="checkbox" data-setting-name="webrtcIPAddressHidden" data-setting-type="bool"><label data-i18n="settingsWebRTCIPAddressHiddenPrompt" for="webrtc-ipaddress-hidden"></label> <a class="fa info important" href="https://github.com/gorhill/uBlock/wiki/Prevent-WebRTC-from-leaking-local-IP-address" target="_blank"></a>
|
||||||
</ul>
|
</ul>
|
||||||
<li class="subgroup"><span data-i18n="settingPerSiteSwitchGroup"></span><ul>
|
<li class="subgroup"><span data-i18n="settingPerSiteSwitchGroup"></span><ul>
|
||||||
|
Loading…
Reference in New Issue
Block a user