Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name avenoel-toolkit
- // @namespace avnt
- // @description toolbar for scroll to top, to bottom, and others later
- // @include https://avenoel.org/*
- // @version 1.01
- // @grant none
- // @require https://cdnjs.cloudflare.com/ajax/libs/zepto/1.1.6/zepto.min.js
- // ==/UserScript==
- "use strict";
- $(document).ready(function () {
- var avnt = {
- addToolBar : function () {
- if ($('#backtotop').length == 0) {
- let gototop_l = "<li class=\'gototop\'><a href='#top'><span class='glyphicon glyphicon-arrow-up'></span></a></li>";
- let gotobottom_l = "<li class=\'gotobottom\'><a href='#bottom'><span class='glyphicon glyphicon-arrow-down'></span></a></li>";
- let gototop_sm = "<li class=\'gototop\'><a href='#top'><span class='glyphicon glyphicon-arrow-up'></span></a></li>";
- let gotobottom_sm = "<li class=\'gotobottom\'><a href='#bottom'><span class='glyphicon glyphicon-arrow-down'></span></a></li>";
- $(".navbar-user li:first-of-type").after(gototop_l);
- $(".navbar-user li:first-of-type").after(gotobottom_l);
- $(".bottombar li:first-of-type").after(gototop_sm);
- $(".bottombar li:first-of-type").after(gotobottom_sm);
- }
- },
- createEventListener : function () {
- $(".avnt .gototop").on('click touchstart', function (e) {
- e.stopPropagation();
- document.body.scrollTop = document.documentElement.scrollTop = 0;
- });
- $(".avnt .gotobottom").on('click touchstart', function (e) {
- e.stopPropagation();
- window.scrollTo(0, document.body.scrollHeight);
- });
- },
- init : function() {
- $("body").addClass("avnt");
- var host = window.location.host;
- switch(host) {
- case "avenoel.org":
- default:
- this.addToolBar();
- this.createEventListener();
- break;
- }
- }
- };
- avnt.init();
- });
Advertisement
Add Comment
Please, Sign In to add comment