Toggle Scrollbars

Toggle the visiblity of scrollbars

当前为 2023-06-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Toggle Scrollbars
  3. // @namespace http://tampermonkey.net/
  4. // @version 1
  5. // @description Toggle the visiblity of scrollbars
  6. // @author atiabbz
  7. // @match *://*/*
  8. // @grant none
  9. // @license GNU GPLv3
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. "use strict";
  14. function injectStyle() {
  15. if (!document.querySelector("#hide-scrollbars")) {
  16. const style = document.createElement("style");
  17. style.id = "hide-scrollbars";
  18. style.innerHTML = `.hide-scrollbars::-webkit-scrollbar { display: none; }`;
  19. document.head.appendChild(style);
  20. }
  21. }
  22.  
  23. document.onkeydown = function toggleScrollbars(e) {
  24. if (e.altKey && e.key === "s") {
  25. injectStyle();
  26. document.body.classList.toggle("hide-scrollbars");
  27. }
  28. };
  29. })();