Sebebeb commited on
Commit
9aeb81a
·
verified ·
1 Parent(s): 2ff06ca

Update shim.js

Browse files
Files changed (1) hide show
  1. shim.js +17 -1
shim.js CHANGED
@@ -151,7 +151,8 @@
151
  reload: '<path d="M21 12a9 9 0 1 1-3-6.7"/><path d="M21 4v5h-5"/>',
152
  go: '<path d="M5 12h14"/><path d="M13 6l6 6-6 6"/>',
153
  up: '<path d="M6 15l6-6 6 6"/>',
154
- down: '<path d="M6 9l6 6 6-6"/>'
 
155
  };
156
  function svg(name) {
157
  return '<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" ' +
@@ -186,6 +187,7 @@
186
  "display:grid;place-items:center;cursor:pointer;padding:0}button:hover{background:#3a3a3a}" +
187
  "input{flex:1;min-width:0;height:28px;border:0;border-radius:6px;padding:0 10px;background:#2d2d2d;" +
188
  "color:#fff;font:inherit;outline:none}input:focus{box-shadow:0 0 0 1px #4f8cff}" +
 
189
  ".tab{position:fixed;top:6px;right:6px;z-index:2147483647;display:none;background:#1e1e1e}" +
190
  "</style>" +
191
  '<div class="bar"><button id="b" title="Back">' + svg("back") + "</button>" +
@@ -193,6 +195,7 @@
193
  '<button id="r" title="Reload">' + svg("reload") + "</button>" +
194
  '<input id="u" spellcheck="false" autocapitalize="off" placeholder="Search or enter address">' +
195
  '<button id="g" title="Go">' + svg("go") + "</button>" +
 
196
  '<button id="c" title="Hide bar">' + svg("up") + "</button></div>" +
197
  '<button class="tab" id="t" title="Show bar">' + svg("down") + "</button>";
198
  document.documentElement.appendChild(barHost);
@@ -208,6 +211,19 @@
208
  root.getElementById("g").onclick = navigate;
209
  input.addEventListener("keydown", function (e) { if (e.key === "Enter") navigate(); });
210
  input.addEventListener("focus", function () { input.select(); });
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  root.getElementById("c").onclick = function () {
212
  bar.style.display = "none"; tab.style.display = "grid";
213
  document.documentElement.style.setProperty("margin-top", "0", "important");
 
151
  reload: '<path d="M21 12a9 9 0 1 1-3-6.7"/><path d="M21 4v5h-5"/>',
152
  go: '<path d="M5 12h14"/><path d="M13 6l6 6-6 6"/>',
153
  up: '<path d="M6 15l6-6 6 6"/>',
154
+ down: '<path d="M6 9l6 6 6-6"/>',
155
+ code: '<path d="M8 6l-6 6 6 6"/><path d="M16 6l6 6-6 6"/>'
156
  };
157
  function svg(name) {
158
  return '<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" ' +
 
187
  "display:grid;place-items:center;cursor:pointer;padding:0}button:hover{background:#3a3a3a}" +
188
  "input{flex:1;min-width:0;height:28px;border:0;border-radius:6px;padding:0 10px;background:#2d2d2d;" +
189
  "color:#fff;font:inherit;outline:none}input:focus{box-shadow:0 0 0 1px #4f8cff}" +
190
+ "button.on{background:#4f8cff;color:#fff}" +
191
  ".tab{position:fixed;top:6px;right:6px;z-index:2147483647;display:none;background:#1e1e1e}" +
192
  "</style>" +
193
  '<div class="bar"><button id="b" title="Back">' + svg("back") + "</button>" +
 
195
  '<button id="r" title="Reload">' + svg("reload") + "</button>" +
196
  '<input id="u" spellcheck="false" autocapitalize="off" placeholder="Search or enter address">' +
197
  '<button id="g" title="Go">' + svg("go") + "</button>" +
198
+ '<button id="j">' + svg("code") + "</button>" +
199
  '<button id="c" title="Hide bar">' + svg("up") + "</button></div>" +
200
  '<button class="tab" id="t" title="Show bar">' + svg("down") + "</button>";
201
  document.documentElement.appendChild(barHost);
 
211
  root.getElementById("g").onclick = navigate;
212
  input.addEventListener("keydown", function (e) { if (e.key === "Enter") navigate(); });
213
  input.addEventListener("focus", function () { input.select(); });
214
+ var jsBtn = root.getElementById("j");
215
+ function nojsOn() { return /(^|;\s*)px_nojs=1/.test(document.cookie); }
216
+ function paintJs() {
217
+ var off = nojsOn();
218
+ jsBtn.className = off ? "on" : "";
219
+ jsBtn.title = off ? "Page scripts are OFF (click to turn on)" : "Page scripts are on (click to turn off)";
220
+ }
221
+ paintJs();
222
+ jsBtn.onclick = function () {
223
+ document.cookie = "px_nojs=" + (nojsOn() ? "0" : "1") +
224
+ "; path=/; max-age=31536000; SameSite=None; Secure";
225
+ location.reload();
226
+ };
227
  root.getElementById("c").onclick = function () {
228
  bar.style.display = "none"; tab.style.display = "grid";
229
  document.documentElement.style.setProperty("margin-top", "0", "important");