Scroll to Top Button

Adds a scroll to top button at the bottom right of the page when scrolled to the bottom, and hides it at the top.

当前为 2024-07-24 提交的版本,查看 最新版本

作者
DXRK1E
评分
0 0 0
版本
1.5
创建于
2024-07-24
更新于
2024-07-24
大小
3.3 KB
许可证
MIT
适用于
所有网站

Scroll to Top Button Userscript

This userscript adds a convenient "Scroll to Top" button to web pages. The button appears at the bottom right of the page when scrolled to the bottom, and hides when at the top. It’s designed to enhance the browsing experience by providing quick navigation back to the top of the page.

Features

  1. Scroll to Top Button: A button that allows users to quickly scroll back to the top of the page.
  2. Visibility Control: The button appears only when the page is scrolled to the bottom and hides when at the top.
  3. Smooth Scrolling: The button uses smooth scrolling for a better user experience.

How It Works

  1. Button Creation:

    • The script creates a button element and styles it with CSS for a modern look.
    • The button is initially hidden using CSS properties opacity and visibility.
  2. Scroll Handling:

    • The handleScroll function checks the scroll position of the page and controls the visibility of the button.
    • The button becomes visible when the user scrolls to the bottom of the page and hides when scrolled up.
  3. Scroll to Top Functionality:

    • When the button is clicked, the page smoothly scrolls to the top using window.scrollTo.

Installation

To use this userscript, you need a userscript manager like Violentmonkey, Tampermonkey, or Greasemonkey. Follow these steps:

  1. Install a Userscript Manager:

  2. Adding the Script:

    • Simply click the button labeled "install the script" at the top.

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址