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(); + } }); }