mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-01 16:33:06 +01:00
Properly handle instances of #?#
or #$#
in picker
Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/issues/1363#issuecomment-734957406
This commit is contained in:
parent
d1895d4749
commit
40a7c47bfc
@ -45,6 +45,8 @@ const svgOcean = svgRoot.children[0];
|
||||
const svgIslands = svgRoot.children[1];
|
||||
const NoPaths = 'M0 0';
|
||||
|
||||
const reCosmeticAnchor = /^#[$?]?#/;
|
||||
|
||||
const epickerId = (( ) => {
|
||||
const url = new URL(self.location.href);
|
||||
if ( url.searchParams.has('zap') ) {
|
||||
@ -144,7 +146,7 @@ const userFilterFromCandidate = function(filter) {
|
||||
const hn = vAPI.hostnameFromURI(docURL.href);
|
||||
|
||||
// Cosmetic filter?
|
||||
if ( filter.startsWith('##') ) {
|
||||
if ( reCosmeticAnchor.test(filter) ) {
|
||||
return hn + filter;
|
||||
}
|
||||
|
||||
@ -460,7 +462,7 @@ const onCandidateChanged = function() {
|
||||
vAPI.MessagingConnection.sendTo(epickerConnectionId, {
|
||||
what: 'dialogSetFilter',
|
||||
filter,
|
||||
compiled: filter.startsWith('##')
|
||||
compiled: reCosmeticAnchor.test(filter)
|
||||
? staticFilteringParser.result.compiled
|
||||
: undefined,
|
||||
});
|
||||
@ -487,13 +489,13 @@ const onCreateClicked = function() {
|
||||
autoComment: true,
|
||||
filters: filter,
|
||||
docURL: docURL.href,
|
||||
killCache: /^#[$?]?#/.test(candidate) === false,
|
||||
killCache: reCosmeticAnchor.test(candidate) === false,
|
||||
});
|
||||
}
|
||||
vAPI.MessagingConnection.sendTo(epickerConnectionId, {
|
||||
what: 'dialogCreate',
|
||||
filter: candidate,
|
||||
compiled: candidate.startsWith('##')
|
||||
compiled: reCosmeticAnchor.test(candidate)
|
||||
? staticFilteringParser.result.compiled
|
||||
: undefined,
|
||||
});
|
||||
|
@ -38,6 +38,8 @@ if ( pickerRoot !== null ) { return; }
|
||||
|
||||
let pickerBootArgs;
|
||||
|
||||
const reCosmeticAnchor = /^#[$?]?#/;
|
||||
|
||||
const netFilterCandidates = [];
|
||||
const cosmeticFilterCandidates = [];
|
||||
|
||||
@ -739,7 +741,7 @@ const filterToDOMInterface = (( ) => {
|
||||
return;
|
||||
}
|
||||
lastFilter = filter;
|
||||
if ( filter.startsWith('##') === false ) {
|
||||
if ( reCosmeticAnchor.test(filter) === false ) {
|
||||
lastResultset = fromNetworkFilter(filter);
|
||||
if ( previewing ) { apply(); }
|
||||
return lastResultset;
|
||||
@ -789,7 +791,7 @@ const filterToDOMInterface = (( ) => {
|
||||
return unapply();
|
||||
}
|
||||
if ( Array.isArray(lastResultset) === false ) { return; }
|
||||
if ( permanent === false || lastFilter.startsWith('##') === false ) {
|
||||
if ( permanent === false || reCosmeticAnchor.test(lastFilter) === false ) {
|
||||
return apply();
|
||||
}
|
||||
if ( vAPI.domFilterer instanceof Object === false ) { return; }
|
||||
|
Loading…
Reference in New Issue
Block a user