您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a scroll to top button to github
This userscript adds a convenient "Scroll to Top" button to GitHub pages. The button remains hidden until you scroll down the page, at which point it smoothly slides into view in the bottom-right corner. Clicking the button provides a smooth scroll animation back to the top of the page.
window.scrollTo({ behavior: 'smooth' })
for a pleasant scroll-to-top experience..application-main
) to appear before adding the button, ensuring compatibility with GitHub's dynamic page loading.@run-at document-start
) to set up an observer.document.body
to be available..application-main
exists.
MutationObserver
to watch for when .application-main
is added to the page.opacity: 0
) and positioned slightly off-screen (transform: translateY(50px)
).transition
is applied for smooth animation effects.scroll
event listener is attached to the window.window.scrollY
) exceeds a threshold (default: 200px).opacity: 1
and transform: translateY(0)
, causing it to slide/fade in.window.scrollTo({ top: 0, behavior: 'smooth' })
.You can adjust the scroll distance required before the button appears by changing the scrollThreshold
variable near the top of the script code (default is 200
). If you modify the script locally, be aware that updates from Greasy Fork might overwrite your changes unless you disable automatic updates for this script in your manager.