From caea4f90fd7428d6085c21f2090e64b42055474a Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Sun, 28 Aug 2022 10:16:36 +0300 Subject: [PATCH] use hostname, add close button to frame --- extension/background.js | 2 +- extension/foreground.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/extension/background.js b/extension/background.js index d1f47cf..804c8c3 100644 --- a/extension/background.js +++ b/extension/background.js @@ -82,7 +82,7 @@ async function injectForeground() { const parsed = new URL(tab.url); askNative({ - domain: parsed.host, + domain: parsed.hostname, }).then(({ results }) => { if (results && results.length) { currentPageMatches = results; diff --git a/extension/foreground.js b/extension/foreground.js index 388924a..ebc827d 100644 --- a/extension/foreground.js +++ b/extension/foreground.js @@ -161,6 +161,27 @@ }); }); autoFillContainer.appendChild(select); + + const close = document.createElement('button'); + close.innerText = 'close'; + Object.assign(close.style, { + right: '0', + border: '0', + position: 'absolute', + padding: '0 4px', + appearance: 'none', + background: 'transparent', + fontWeight: 'bold', + fontSize: '12px', + pointerEvents: 'all' + }); + autoFillContainer.appendChild(close); + + close.addEventListener('click', () => { + autoFillContainer.parentElement.removeChild(autoFillContainer); + window.removeEventListener('resize', reposition); + window.removeEventListener('scroll', reposition); + }); } function init() {