Update Wayback Machine Toolbar Toggler to 1.1.0

- Sync up the toolbar hidden state for all tabs
This commit is contained in:
blankie 2023-08-12 16:32:25 +10:00
parent 35231b7410
commit f733e10bda
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 15 additions and 2 deletions

View File

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