您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
吾爱破解论坛左侧文章目录可滚动,鼠标滚轮可以上下移动较长的目录
当前为
// ==UserScript== // @name 吾爱破解论坛左侧文章目录可滚动 // @namespace https://www.52pojie.cn/thread-712090-1-1.html // @version 0.1 // @description 吾爱破解论坛左侧文章目录可滚动,鼠标滚轮可以上下移动较长的目录 // @author Ganlv // @match https://www.52pojie.cn/* // @icon https://www.52pojie.cn/favicon.ico // @grant none // ==/UserScript== (function () { var tocSideElements = document.querySelectorAll('.toc-side'); window.addEventListener('scroll', function (e) { for (var i = 0; i < tocSideElements.length; ++i) { var tocSide = tocSideElements[i]; var tocSideRect = tocSide.getBoundingClientRect(); var tocSideMarginBottom = parseInt(window.getComputedStyle(tocSide).getPropertyValue('margin-bottom')); var tocSideHeight = window.innerHeight - tocSideMarginBottom - tocSideRect.top; if (tocSideHeight < tocSide.scrollHeight) { tocSide.style.height = tocSideHeight + 'px'; } else { tocSide.style.height = ''; } } }); for (var i = 0; i < tocSideElements.length; ++i) { (function (tocSide) { tocSide.addEventListener('wheel', function (e) { if (e.deltaY > 0 && tocSide.scrollTop + tocSide.offsetHeight > tocSide.scrollHeight - 1 || e.deltaY < 0 && tocSide.scrollTop < 1) { e.preventDefault(); } }); })(tocSideElements[i]); } var style = document.createElement('style'); style.textContent = '.toc-side { overflow-y: scroll; } .toc-side::-webkit-scrollbar { width: 0 !important; }'; document.querySelector('head').appendChild(style); })();