mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Fine tune new exceptor code
Related feedback:
- a91781a495 (commitcomment-93128519)
For instance, do not make exceptor widget available for
exceptions from filter lists.
This commit is contained in:
parent
e2c3917ecd
commit
fa5e4b7769
1 changed files with 21 additions and 17 deletions
|
@ -1124,6 +1124,7 @@ const reloadTab = function(ev) {
|
|||
'csp_report': 'other',
|
||||
};
|
||||
const createdStaticFilters = {};
|
||||
const reIsExceptionFilter = /^@@|^[\w.-]*?#@#/;
|
||||
|
||||
let dialog = null;
|
||||
let targetRow = null;
|
||||
|
@ -1136,7 +1137,7 @@ const reloadTab = function(ev) {
|
|||
let targetPageDomain;
|
||||
let targetFrameDomain;
|
||||
|
||||
const uglyTypeFromSelector = function(pane) {
|
||||
const uglyTypeFromSelector = pane => {
|
||||
const prettyType = selectValue('select.type.' + pane);
|
||||
if ( pane === 'static' ) {
|
||||
return staticFilterTypes[prettyType] || prettyType;
|
||||
|
@ -1144,18 +1145,23 @@ const reloadTab = function(ev) {
|
|||
return uglyRequestTypes[prettyType] || prettyType;
|
||||
};
|
||||
|
||||
const selectNode = function(selector) {
|
||||
const selectNode = selector => {
|
||||
return qs$(dialog, selector);
|
||||
};
|
||||
|
||||
const selectValue = function(selector) {
|
||||
const selectValue = selector => {
|
||||
return selectNode(selector).value || '';
|
||||
};
|
||||
|
||||
const staticFilterNode = function() {
|
||||
const staticFilterNode = ( ) => {
|
||||
return qs$(dialog, 'div.panes > div.static textarea');
|
||||
};
|
||||
|
||||
const toExceptionFilter = (filter, extended) => {
|
||||
if ( reIsExceptionFilter.test(filter) ) { return filter; }
|
||||
return extended ? filter.replace('##', '#@#') : `@@${filter}`;
|
||||
};
|
||||
|
||||
const onColorsReady = function(response) {
|
||||
dom.cl.toggle(dom.body, 'dirty', response.dirty);
|
||||
for ( const url in response.colors ) {
|
||||
|
@ -1247,12 +1253,9 @@ const reloadTab = function(ev) {
|
|||
if ( tcl.contains('exceptor') ) {
|
||||
ev.stopPropagation();
|
||||
const filter = filterFromTargetRow();
|
||||
const exceptedFilter = dom.cl.has(targetRow, 'extendedRealm')
|
||||
? `#@#${filter.replace(/^.*?#@?#/, '')}`
|
||||
: `@@${filter.replace(/^@@/, '')}`;
|
||||
const status = await messaging.send('loggerUI', {
|
||||
what: 'toggleInMemoryFilter',
|
||||
filter: exceptedFilter,
|
||||
filter: toExceptionFilter(filter, dom.cl.has(targetRow, 'extendedRealm')),
|
||||
});
|
||||
const row = target.closest('div');
|
||||
dom.cl.toggle(row, 'exceptored', status);
|
||||
|
@ -1480,16 +1483,17 @@ const reloadTab = function(ev) {
|
|||
|
||||
const toSummaryPaneFilterNode = async function(receiver, filter) {
|
||||
receiver.children[1].textContent = filter;
|
||||
if ( filterAuthorMode !== true ) { return; }
|
||||
if ( dom.cl.has(targetRow, 'canLookup') === false ) { return; }
|
||||
const exceptedFilter = dom.cl.has(targetRow, 'extendedRealm')
|
||||
? `#@#${filter.replace(/^.*?#@?#/, '')}`
|
||||
: `@@${filter.replace(/^@@/, '')}`;
|
||||
const isTemporaryException = await messaging.send('loggerUI', {
|
||||
what: 'hasInMemoryFilter',
|
||||
filter: exceptedFilter,
|
||||
});
|
||||
dom.cl.toggle(receiver, 'exceptored', isTemporaryException);
|
||||
const isException = reIsExceptionFilter.test(filter);
|
||||
let isExcepted = false;
|
||||
if ( isException ) {
|
||||
isExcepted = await messaging.send('loggerUI', {
|
||||
what: 'hasInMemoryFilter',
|
||||
filter: toExceptionFilter(filter, dom.cl.has(targetRow, 'extendedRealm')),
|
||||
});
|
||||
}
|
||||
if ( isException && isExcepted === false ) { return; }
|
||||
dom.cl.toggle(receiver, 'exceptored', isExcepted);
|
||||
receiver.children[2].style.visibility = '';
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue