Hides scrollbars globally but keeps scrolling functionality
当前为
// ==UserScript==
// @name Scrollbar Hider
// @description Hides scrollbars globally but keeps scrolling functionality
// @author SSL-ACTX
// @version 1.0.1
// @license MIT
// @grant none
// @run-at document-start
// @match *://*/*
// @namespace https://greasyfork.org/users/1365732
// ==/UserScript==
(function() {
'use strict';
// CSS rules to hide scrollbars but retain scrolling functionality :)
const scrollbarHiderCSS = `
/* Remove WebKit-based browsers' scrollbars */
*::-webkit-scrollbar {
width: 0;
height: 0;
}
/* Hide scrollbars in Firefox, IE, and Edge */
* {
scrollbar-width: none;
-ms-overflow-style: none;
}
`;
/**
* Injects the provided CSS into the document.
*/
const injectCSS = (cssRules) => {
const styleElement = document.createElement('style');
styleElement.type = 'text/css';
styleElement.textContent = cssRules;
document.head.appendChild(styleElement);
};
/**
* Applies the CSS for hiding scrollbars by injecting it manually.
*/
const applyScrollbarHider = () => {
injectCSS(scrollbarHiderCSS);
};
applyScrollbarHider();
})();