From 8060ddb2834604cfed31316a4ee527635f8027b7 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 14 Dec 2020 11:26:04 -0500 Subject: [PATCH] Avoid duplicates in editor's auto-completion of origins Related commit: - https://github.com/gorhill/uBlock/commit/daf464b3c30e9c0c5f5991ba1bde8f9dca1d7078 --- src/js/messaging.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/messaging.js b/src/js/messaging.js index 4e7b750b1..1566c709d 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -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