Plain is headed towards 1.0! Subscribe for development updates →

 1// Make this available to the JS console for the user
 2var plainToolbar = {
 3  hide: function () {
 4    // Hide by inserting a style so it doesn't flash on page load
 5    var style = document.createElement("style");
 6    style.innerHTML = "#plaintoolbar { display: none; }";
 7    document.getElementsByTagName("head")[0].appendChild(style);
 8    this.stylesheet = style;
 9  },
10  show: function () {
11    localStorage.removeItem("plaintoolbar.hidden_until");
12    if (this.stylesheet) {
13      this.stylesheet.remove();
14    }
15  },
16  shouldHide: function () {
17    var hiddenUntil = localStorage.getItem("plaintoolbar.hidden_until");
18    if (hiddenUntil) {
19      if (Date.now() < hiddenUntil) {
20        return true;
21      } else {
22        localStorage.removeItem("plaintoolbar.hidden_until");
23        return false;
24      }
25    }
26    return false;
27  },
28  hideUntil: function (until) {
29    localStorage.setItem("plaintoolbar.hidden_until", until);
30    this.hide();
31  },
32  toggleExpand: function () {
33    this.expanded = !this.expanded;
34    document.querySelector("#plaintoolbar-details").classList.toggle("hidden");
35  },
36};
37
38// Render it hidden immediately if the user has hidden it before
39if (plainToolbar.shouldHide()) {
40  plainToolbar.hide();
41}
42
43window.addEventListener("load", function () {
44    document.querySelector('[data-plaintoolbar-hide]').addEventListener('click', function() {
45        console.log("Hiding staff toolbar for 1 hour");
46        plainToolbar.hideUntil(Date.now() + 3600000);
47    });
48    document.querySelector('[data-plaintoolbar-expand]').addEventListener('click', function() {
49        plainToolbar.toggleExpand();
50    });
51});