+23
-25
lines changedFilter options
+23
-25
lines changed Original file line number Diff line number Diff line change
@@ -53,9 +53,9 @@ const epickerId = (( ) => {
53
53
})();
54
54
if ( epickerId === null ) { return; }
55
55
56
+
const docURL = new URL(vAPI.getURL(''));
57
+
56
58
let epickerConnectionId;
57
-
let filterHostname = '';
58
-
let filterOrigin = '';
59
59
let resultsetOpt;
60
60
61
61
let netFilterCandidates = [];
@@ -102,17 +102,19 @@ const renderRange = function(id, value, invert = false) {
102
102
const userFilterFromCandidate = function(filter) {
103
103
if ( filter === '' || filter === '!' ) { return; }
104
104
105
+
const hn = vAPI.hostnameFromURI(docURL.href);
106
+
105
107
// Cosmetic filter?
106
108
if ( filter.startsWith('##') ) {
107
-
return filterHostname + filter;
109
+
return hn + filter;
108
110
}
109
111
110
112
// Assume net filter
111
113
const opts = [];
112
114
113
115
// If no domain included in filter, we need domain option
114
116
if ( filter.startsWith('||') === false ) {
115
-
opts.push(`domain=${filterHostname}`);
117
+
opts.push(`domain=${hn}`);
116
118
}
117
119
118
120
if ( resultsetOpt !== undefined ) {
@@ -416,8 +418,7 @@ const onCreateClicked = function() {
416
418
what: 'createUserFilter',
417
419
autoComment: true,
418
420
filters: filter,
419
-
origin: filterOrigin,
420
-
pageDomain: filterHostname,
421
+
docURL: docURL.href,
421
422
killCache: /^#[$?]?#/.test(candidate) === false,
422
423
});
423
424
}
@@ -672,13 +673,7 @@ const showDialog = function(details) {
672
673
}
673
674
cosmeticFilterCandidates = cosmeticFilters;
674
675
675
-
// https://github.com/gorhill/uBlock/issues/738
676
-
// Trim dots.
677
-
filterHostname = details.hostname;
678
-
if ( filterHostname.slice(-1) === '.' ) {
679
-
filterHostname = filterHostname.slice(0, -1);
680
-
}
681
-
filterOrigin = details.origin;
676
+
docURL.href = details.url;
682
677
683
678
populateCandidates(netFilters, '#netFilters');
684
679
populateCandidates(cosmeticFilters, '#cosmeticFilters');
Original file line number Diff line number Diff line change
@@ -1263,13 +1263,16 @@ const reloadTab = function(ev) {
1263
1263
// Avoid duplicates
1264
1264
if ( createdStaticFilters.hasOwnProperty(value) ) { return; }
1265
1265
createdStaticFilters[value] = true;
1266
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/1281#issuecomment-704217175
1267
+
// TODO:
1268
+
// Figure a way to use the actual document URL. Currently using
1269
+
// a synthetic URL derived from the document hostname.
1266
1270
if ( value !== '' ) {
1267
1271
messaging.send('loggerUI', {
1268
1272
what: 'createUserFilter',
1269
1273
autoComment: true,
1270
1274
filters: value,
1271
-
origin: targetPageDomain,
1272
-
pageDomain: targetPageDomain,
1275
+
docURL: `https://${targetFrameHostname}/`,
1273
1276
});
1274
1277
}
1275
1278
updateWidgets();
@@ -1872,8 +1875,6 @@ const reloadTab = function(ev) {
1872
1875
);
1873
1876
})();
1874
1877
1875
-
// https://www.youtube.com/watch?v=XyNYrmmdUd4
1876
-
1877
1878
/******************************************************************************/
1878
1879
/******************************************************************************/
1879
1880
Original file line number Diff line number Diff line change
@@ -843,8 +843,7 @@ const onOptmizeCandidate = function(details) {
843
843
const showDialog = function(options) {
844
844
vAPI.MessagingConnection.sendTo(epickerConnectionId, {
845
845
what: 'showDialog',
846
-
hostname: self.location.hostname,
847
-
origin: self.location.origin,
846
+
url: self.location.href,
848
847
netFilters: netFilterCandidates,
849
848
cosmeticFilters: cosmeticFilterCandidates,
850
849
filter: bestCandidateFilter,
Original file line number Diff line number Diff line change
@@ -399,12 +399,15 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
399
399
// Date in YYYY-MM-DD format - https://stackoverflow.com/a/50130338
400
400
const ISO8061Date = new Date(d.getTime() +
401
401
(d.getTimezoneOffset()*60000)).toISOString().split('T')[0];
402
+
const url = new URL(options.docURL);
402
403
comment =
403
404
'! ' +
404
405
this.hiddenSettings.autoCommentFilterTemplate
405
406
.replace('{{date}}', ISO8061Date)
406
407
.replace('{{time}}', d.toLocaleTimeString())
407
-
.replace('{{origin}}', options.origin);
408
+
.replace('{{hostname}}', url.hostname)
409
+
.replace('{{origin}}', url.origin)
410
+
.replace('{{url}}', url.href);
408
411
}
409
412
410
413
const details = await this.loadUserFilters();
@@ -414,10 +417,7 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
414
417
// from the last comment found in the user filter list.
415
418
if ( comment !== '' ) {
416
419
const pos = details.content.lastIndexOf(comment);
417
-
if (
418
-
pos === -1 ||
419
-
details.content.indexOf('\n!', pos + 1) !== -1
420
-
) {
420
+
if ( pos === -1 || details.content.indexOf('\n!', pos + 1) !== -1 ) {
421
421
filters = '\n' + comment + '\n' + filters;
422
422
}
423
423
}
@@ -462,7 +462,10 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
462
462
µBlock.createUserFilters = function(details) {
463
463
this.appendUserFilters(details.filters, details);
464
464
// https://github.com/gorhill/uBlock/issues/1786
465
-
this.cosmeticFilteringEngine.removeFromSelectorCache(details.pageDomain);
465
+
if ( details.docURL === undefined ) { return; }
466
+
this.cosmeticFilteringEngine.removeFromSelectorCache(
467
+
vAPI.hostnameFromURI(details.docURL)
468
+
);
466
469
};
467
470
468
471
/******************************************************************************/
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4