mirror of https://github.com/gorhill/uBlock.git
Fix contextual menu quirks
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/3382
This commit is contained in:
parent
b3ffba7238
commit
0a6dc47a72
|
@ -19,12 +19,8 @@
|
||||||
Home: https://github.com/gorhill/uBlock
|
Home: https://github.com/gorhill/uBlock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
import µb from './background.js';
|
|
||||||
import { i18n$ } from './i18n.js';
|
import { i18n$ } from './i18n.js';
|
||||||
|
import µb from './background.js';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
@ -55,18 +51,23 @@ const onBlockElement = function(details, tab) {
|
||||||
let src = details.frameUrl || details.srcUrl || details.linkUrl || '';
|
let src = details.frameUrl || details.srcUrl || details.linkUrl || '';
|
||||||
|
|
||||||
if ( !tagName ) {
|
if ( !tagName ) {
|
||||||
if ( typeof details.frameUrl === 'string' ) {
|
if ( typeof details.frameUrl === 'string' && details.frameId !== 0 ) {
|
||||||
tagName = 'iframe';
|
tagName = 'iframe';
|
||||||
|
src = details.srcUrl;
|
||||||
} else if ( typeof details.srcUrl === 'string' ) {
|
} else if ( typeof details.srcUrl === 'string' ) {
|
||||||
if ( details.mediaType === 'image' ) {
|
if ( details.mediaType === 'image' ) {
|
||||||
tagName = 'img';
|
tagName = 'img';
|
||||||
|
src = details.srcUrl;
|
||||||
} else if ( details.mediaType === 'video' ) {
|
} else if ( details.mediaType === 'video' ) {
|
||||||
tagName = 'video';
|
tagName = 'video';
|
||||||
|
src = details.srcUrl;
|
||||||
} else if ( details.mediaType === 'audio' ) {
|
} else if ( details.mediaType === 'audio' ) {
|
||||||
tagName = 'audio';
|
tagName = 'audio';
|
||||||
|
src = details.srcUrl;
|
||||||
}
|
}
|
||||||
} else if ( typeof details.linkUrl === 'string' ) {
|
} else if ( typeof details.linkUrl === 'string' ) {
|
||||||
tagName = 'a';
|
tagName = 'a';
|
||||||
|
src = details.linkUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,27 +201,25 @@ let currentBits = 0;
|
||||||
|
|
||||||
const update = function(tabId = undefined) {
|
const update = function(tabId = undefined) {
|
||||||
let newBits = 0;
|
let newBits = 0;
|
||||||
if (
|
if ( µb.userSettings.contextMenuEnabled ) {
|
||||||
µb.userSettings.contextMenuEnabled &&
|
const pageStore = tabId && µb.pageStoreFromTabId(tabId) || null;
|
||||||
µb.userFiltersAreEnabled() &&
|
if ( pageStore?.getNetFilteringSwitch() ) {
|
||||||
tabId !== undefined
|
if ( µb.userFiltersAreEnabled() ) {
|
||||||
) {
|
|
||||||
const pageStore = µb.pageStoreFromTabId(tabId);
|
|
||||||
if ( pageStore && pageStore.getNetFilteringSwitch() ) {
|
|
||||||
if ( pageStore.shouldApplySpecificCosmeticFilters(0) ) {
|
if ( pageStore.shouldApplySpecificCosmeticFilters(0) ) {
|
||||||
newBits |= BLOCK_ELEMENT_BIT;
|
newBits |= BLOCK_ELEMENT_BIT;
|
||||||
} else {
|
} else {
|
||||||
newBits |= BLOCK_RESOURCE_BIT;
|
newBits |= BLOCK_RESOURCE_BIT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ( pageStore.largeMediaCount !== 0 ) {
|
if ( pageStore.largeMediaCount !== 0 ) {
|
||||||
newBits |= TEMP_ALLOW_LARGE_MEDIA_BIT;
|
newBits |= TEMP_ALLOW_LARGE_MEDIA_BIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newBits |= SUBSCRIBE_TO_LIST_BIT;
|
|
||||||
}
|
|
||||||
if ( µb.hiddenSettings.filterAuthorMode ) {
|
if ( µb.hiddenSettings.filterAuthorMode ) {
|
||||||
newBits |= VIEW_SOURCE_BIT;
|
newBits |= VIEW_SOURCE_BIT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
newBits |= SUBSCRIBE_TO_LIST_BIT;
|
||||||
if ( newBits === currentBits ) { return; }
|
if ( newBits === currentBits ) { return; }
|
||||||
currentBits = newBits;
|
currentBits = newBits;
|
||||||
const usedEntries = [];
|
const usedEntries = [];
|
||||||
|
|
Loading…
Reference in New Issue