From 3ba0d5a33da5ff76f527284087ba80366309482e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20I=C3=9Fbr=C3=BCcker?= Date: Sun, 1 Jan 2023 22:39:22 +0100 Subject: [PATCH] fix: prevent navigation when loading homepage --- newtab.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/newtab.js b/newtab.js index c09d83e..2f6090b 100644 --- a/newtab.js +++ b/newtab.js @@ -10,8 +10,9 @@ // When we navigate away from the homepage, navigate the top level instead const currTab = await browser.tabs.getCurrent() browser.webNavigation.onBeforeNavigate.addListener(e => { + const isNotHomepage = e.url.indexOf(homepageRaw) === -1; console.log(e) - if (e.tabId === currTab.id && e.frameId !== 0 && e.parentFrameId === 0) { + if (e.tabId === currTab.id && e.frameId !== 0 && e.parentFrameId === 0 && isNotHomepage) { window.location.href = e.url } })