🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Kaskus - Scroll to Top

Add button on Kaskus topbar to quickly scroll to top.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

/* This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://www.wtfpl.net/ for more details. */

// ==UserScript==
// @id              kaskus-scroll-to-top@loucypher
// @name            Kaskus - Scroll to Top
// @namespace       https://userscripts.org/users/12
// @description     Add button on Kaskus topbar to quickly scroll to top.
// @version         1.0
// @author          LouCypher
// @license         WTFPL
// @screenshot      https://mediacru.sh/Qjrp3WGaeeWD.png
// @icon            http://loucypher.github.io/userscripts/kaskus/kaskus-48.png
// @icon64URL       http://loucypher.github.io/userscripts/kaskus/kaskus-64.png
// @contributionURL http://loucypher.github.io/userscripts/donate.html?Kaskus+-+Scroll+to+Top
// @homepageURL     https://greasyfork.org/scripts/3
// @supportURL      https://greasyfork.org/scripts/3
// @resource        CHANGELOG https://raw.github.com/LouCypher/userscripts/master/kaskus/scroll-to-top/CHANGELOG.txt
// @resource        LICENSE https://raw.github.com/LouCypher/userscripts/master/licenses/WTFPL/LICENSE.txt
// @include         http://www.kaskus.co.id/*
// @grant           unsafeWindow
// @grant           GM_addStyle
// ==/UserScript==

function $(aSelector, aNode) {
  return (aNode || document).querySelector(aSelector);
}

function scrollToTop(aEvent) {
  aEvent.preventDefault();
  if (pageYOffset >= 1)
    unsafeWindow.jQuery("html").animate({scrollTop: 0}, "fast");
}

function showButton() {
  if (pageYOffset >= header.offsetHeight)
    $("#scroll-to-top").className = "";
  else
    $("#scroll-to-top").className = "hide";
}

var css = ".rotate-right::before{-moz-transform:rotate(90deg);"
        + "-webkit-transform:rotate(90deg);transform:rotate(90deg);font-size:15px;}"
        + "#scroll-to-top{text-align:center;width:25px;top:4px;"
        + (typeof opera === "object"
           // Opera
           ? "position:fixed;right:1em;background:#1484ce;"
           // other browsers that support CSS calc() function
           : "position:absolute;left:-moz-calc(50% - 12.5px);" +
             "left:-webkit-calc(50% - 12.5px);left:calc(50% - 12.5px);")
        + "}";

var header = $("#site-header .meta-header");
var row = $(".row", header);
if (row) {
  GM_addStyle(css);
  var link = row.insertBefore(document.createElement("a"), row.firstChild);
  link.id = "scroll-to-top";
  link.className = "hide";
  link.href = "#";
  link.rel = "tooltip";
  link.dataset.title = "Scroll to Top";
  link.dataset.placement = "bottom";
  link.innerHTML = '<i class="icon-step-backward header-icon rotate-right"></i>';
  link.addEventListener("click", scrollToTop);
  window.addEventListener("scroll", showButton);
  showButton();
}