您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add a 'go to top' button for Google
当前为
- // ==UserScript==
- // @name Go to Top -- Google
- // @namespace feifeihang.info
- // @description Add a 'go to top' button for Google
- // @include https://www.google.*
- // @include http://www.google.*
- // @version 3
- // @grant none
- // ==/UserScript==
- (function (window, document, undefined) {
- // create the goto-top button.
- var btn = document.createElement('div');
- btn.id = 'goto-top-btn';
- btn.innerHTML = 'TOP';
- btn.onclick = gotoTop;
- // set CSS style.
- btn.style = 'display: none; color: #fff; position: fixed; bottom: 10px;' +
- 'right: 10px; line-height: 40px; text-align: center;' +
- 'width: 40px; height: 40px; background: #4285F4;' +
- 'cursor: pointer; font-weight: bolder; opacity: 0.8;';
- // append the go-to-top to search form to successfully attach to the UI.
- var form = document.querySelector('#searchform');
- form.appendChild(btn);
- window.onload = function () {
- var doc = document.documentElement;
- var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
- if (top !== 0) {
- btn.style.display = 'block';
- }
- }
- // bind button hiden/show event.
- window.onscroll = function() {
- var doc = document.documentElement;
- var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
- if (top === 0) {
- btn.style.display = 'none';
- } else {
- btn.style.display = 'block';
- }
- }
- function gotoTop() {
- goto(Math.floor(window.pageYOffset / 5));
- }
- function goto(step) {
- setTimeout(function () {
- window.scrollTo(0, window.pageYOffset - step);
- if (window.pageYOffset <= 0) return;
- goto(step);
- }, 100);
- }
- })(window, document, undefined);
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址