1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00

Avoid duplicates in editor's auto-completion of origins

Related commit:
- daf464b3c3
This commit is contained in:
Raymond Hill 2020-12-14 11:26:04 -05:00
parent b22cf24bd5
commit 8060ddb283
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1048,7 +1048,7 @@ const getLists = async function(callback) {
// TODO: also return origin of embedded frames?
const getOriginHints = function() {
const punycode = self.punycode;
const out = [];
const out = new Set();
for ( const tabId of µb.pageStores.keys() ) {
if ( tabId === -1 ) { continue; }
const tabContext = µb.tabContextManager.lookup(tabId);
@ -1056,11 +1056,11 @@ const getOriginHints = function() {
let { rootDomain, rootHostname } = tabContext;
if ( rootDomain.endsWith('-scheme') ) { continue; }
const isPunycode = rootHostname.includes('xn--');
out.push(isPunycode ? punycode.toUnicode(rootDomain) : rootDomain);
out.add(isPunycode ? punycode.toUnicode(rootDomain) : rootDomain);
if ( rootHostname === rootDomain ) { continue; }
out.push(isPunycode ? punycode.toUnicode(rootHostname) : rootHostname);
out.add(isPunycode ? punycode.toUnicode(rootHostname) : rootHostname);
}
return out;
return Array.from(out);
};
// My rules