mirror of https://github.com/gorhill/uBlock.git
remove context menu entry and picker tools for whitelisted sites
This commit is contained in:
parent
89c073f3e9
commit
8b5a7aa398
|
@ -1,7 +1,7 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
uBlock Origin - a browser extension to block requests.
|
uBlock Origin - a browser extension to block requests.
|
||||||
Copyright (C) 2014-2017 Raymond Hill
|
Copyright (C) 2014-present 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
|
||||||
|
@ -33,19 +33,13 @@ if ( vAPI.contextMenu === undefined ) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var µb = µBlock;
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var onBlockElement = function(details, tab) {
|
var onBlockElement = function(details, tab) {
|
||||||
if ( tab === undefined ) {
|
if ( tab === undefined ) { return; }
|
||||||
return;
|
if ( /^https?:\/\//.test(tab.url) === false ) { return; }
|
||||||
}
|
let tagName = details.tagName || '';
|
||||||
if ( /^https?:\/\//.test(tab.url) === false ) {
|
let src = details.frameUrl || details.srcUrl || details.linkUrl || '';
|
||||||
return;
|
|
||||||
}
|
|
||||||
var tagName = details.tagName || '';
|
|
||||||
var src = details.frameUrl || details.srcUrl || details.linkUrl || '';
|
|
||||||
|
|
||||||
if ( !tagName ) {
|
if ( !tagName ) {
|
||||||
if ( typeof details.frameUrl === 'string' ) {
|
if ( typeof details.frameUrl === 'string' ) {
|
||||||
|
@ -63,14 +57,14 @@ var onBlockElement = function(details, tab) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
µb.elementPickerExec(tab.id, tagName + '\t' + src);
|
µBlock.elementPickerExec(tab.id, tagName + '\t' + src);
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var onTemporarilyAllowLargeMediaElements = function(details, tab) {
|
var onTemporarilyAllowLargeMediaElements = function(details, tab) {
|
||||||
if ( tab === undefined ) { return; }
|
if ( tab === undefined ) { return; }
|
||||||
var pageStore = µb.pageStoreFromTabId(tab.id);
|
let pageStore = µBlock.pageStoreFromTabId(tab.id);
|
||||||
if ( pageStore === null ) { return; }
|
if ( pageStore === null ) { return; }
|
||||||
pageStore.temporarilyAllowLargeMediaElements(true);
|
pageStore.temporarilyAllowLargeMediaElements(true);
|
||||||
};
|
};
|
||||||
|
@ -106,21 +100,19 @@ var menuEntries = [
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var update = function(tabId) {
|
var update = function(tabId) {
|
||||||
var newBits = 0;
|
let newBits = 0;
|
||||||
if ( µb.userSettings.contextMenuEnabled && tabId !== null ) {
|
if ( µBlock.userSettings.contextMenuEnabled && tabId !== null ) {
|
||||||
var pageStore = µb.pageStoreFromTabId(tabId);
|
let pageStore = µBlock.pageStoreFromTabId(tabId);
|
||||||
if ( pageStore ) {
|
if ( pageStore && pageStore.getNetFilteringSwitch() ) {
|
||||||
newBits |= 0x01;
|
newBits |= 0x01;
|
||||||
if ( pageStore.largeMediaCount !== 0 ) {
|
if ( pageStore.largeMediaCount !== 0 ) {
|
||||||
newBits |= 0x02;
|
newBits |= 0x02;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( newBits === currentBits ) {
|
if ( newBits === currentBits ) { return; }
|
||||||
return;
|
|
||||||
}
|
|
||||||
currentBits = newBits;
|
currentBits = newBits;
|
||||||
var usedEntries = [];
|
let usedEntries = [];
|
||||||
if ( newBits & 0x01 ) {
|
if ( newBits & 0x01 ) {
|
||||||
usedEntries.push(menuEntries[0]);
|
usedEntries.push(menuEntries[0]);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +130,7 @@ vAPI.contextMenu.onMustUpdate = update;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
update: function(tabId) {
|
update: function(tabId) {
|
||||||
if ( µb.userSettings.contextMenuEnabled && tabId === undefined ) {
|
if ( µBlock.userSettings.contextMenuEnabled && tabId === undefined ) {
|
||||||
vAPI.tabs.get(null, function(tab) {
|
vAPI.tabs.get(null, function(tab) {
|
||||||
if ( tab ) {
|
if ( tab ) {
|
||||||
update(tab.id);
|
update(tab.id);
|
||||||
|
|
|
@ -325,7 +325,7 @@ var popupDataFromTabId = function(tabId, tabTitle) {
|
||||||
r.hostnameDict = getHostnameDict(pageStore.hostnameToCountMap);
|
r.hostnameDict = getHostnameDict(pageStore.hostnameToCountMap);
|
||||||
r.contentLastModified = pageStore.contentLastModified;
|
r.contentLastModified = pageStore.contentLastModified;
|
||||||
r.firewallRules = getFirewallRules(rootHostname, r.hostnameDict);
|
r.firewallRules = getFirewallRules(rootHostname, r.hostnameDict);
|
||||||
r.canElementPicker = µb.URI.isNetworkURI(r.rawURL);
|
r.canElementPicker = µb.URI.isNetworkURI(r.rawURL) && r.netFilteringSwitch;
|
||||||
r.noPopups = µb.sessionSwitches.evaluateZ('no-popups', rootHostname);
|
r.noPopups = µb.sessionSwitches.evaluateZ('no-popups', rootHostname);
|
||||||
r.popupBlockedCount = pageStore.popupBlockedCount;
|
r.popupBlockedCount = pageStore.popupBlockedCount;
|
||||||
r.noCosmeticFiltering = µb.sessionSwitches.evaluateZ('no-cosmetic-filtering', rootHostname);
|
r.noCosmeticFiltering = µb.sessionSwitches.evaluateZ('no-cosmetic-filtering', rootHostname);
|
||||||
|
|
Loading…
Reference in New Issue