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

Greasy fork 爱吃馍镜像

Kaskus - Scroll to Top

Add button on Kaskus topbar to quickly scroll to top.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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

公众号二维码

扫码关注【爱吃馍】

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

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل 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();
}