From 7e7839bb1ec4d9770a1a169e1e2683bd290f7df1 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 30 Jul 2020 04:30:00 +0300 Subject: [PATCH] avoid adding # to the page URL when clicking dummy links (#1006) --- js/dom.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/dom.js b/js/dom.js index 77e4f2eb..5b1d39b4 100644 --- a/js/dom.js +++ b/js/dom.js @@ -85,6 +85,12 @@ onDOMready().then(() => { // set language for CSS :lang and [FF-only] hyphenation document.documentElement.setAttribute('lang', chrome.i18n.getUILanguage()); +// avoid adding # to the page URL when clicking dummy links +document.addEventListener('click', e => { + if (e.target.closest('a[href="#"]')) { + e.preventDefault(); + } +}); function onDOMready() { if (document.readyState !== 'loading') {