From f733e10bda3cf35f9d19a0a6cead02bfd1785a25 Mon Sep 17 00:00:00 2001 From: blankie Date: Sat, 12 Aug 2023 16:32:25 +1000 Subject: [PATCH] Update Wayback Machine Toolbar Toggler to 1.1.0 - Sync up the toolbar hidden state for all tabs --- Wayback Machine Toolbar Toggler.user.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Wayback Machine Toolbar Toggler.user.js b/Wayback Machine Toolbar Toggler.user.js index b1abed3..124185f 100644 --- a/Wayback Machine Toolbar Toggler.user.js +++ b/Wayback Machine Toolbar Toggler.user.js @@ -4,7 +4,8 @@ // @match https://web.archive.org/web/* // @grant GM.getValue // @grant GM.setValue -// @version 1.0.0 +// @grant GM_addValueChangeListener +// @version 1.1.0 // @author blankie // @description Replaces the "close this toolbar" button with one that lets you reopen the toolbar; its collapsed state is also saved // @inject-into page @@ -22,6 +23,7 @@ function hideToolbar() { let openA = wmIpp.querySelector("#wmtt-open-toolbar"); let baseHeight = wmIpp.querySelector("#donato").offsetHeight + openA.offsetHeight + (wmIpp.querySelector("#wm-ipp-inside").offsetHeight - wmIpp.querySelector("#wm-capinfo").offsetHeight); wmIppBase.style.height = `${baseHeight}px`; + openA.style.display = ""; GM.setValue("autoHideToolbar", true).catch(function(error) { @@ -91,7 +93,18 @@ function handleWmIpp() { hideToolbar(); } }).catch(function(error) { - console.log("Failed to fetch autoHideToolbar:", error); + console.error("Failed to fetch autoHideToolbar:", error); + }); + GM_addValueChangeListener("autoHideToolbar", function(name, oldValue, autoHideToolbar, remote) { + if (!remote) { + return; + } + + if (autoHideToolbar) { + hideToolbar(); + } else { + showToolbar(); + } }); }