Advertisement
decembre

GM - Scroll To Top/Bottom Of Page (Tweaked For ICONS)

Jan 8th, 2014
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           Scroll To Top/Bottom Of Page (ICONS)
  3. // @namespace      http://userscripts.org/users/23652
  4. // @description    Adds a link to scroll to the top or bottom of the current page
  5. // @include        http://*
  6. // @include        https://*
  7. // @copyright      JoeSimmons
  8. // @version        1.0.4
  9. // @license        Creative Commons Attribution-Noncommercial 3.0 United States License
  10. // ==/UserScript==
  11.      
  12.     if(!parent || parent.location!=location) return;
  13.      
  14.     function gotop() {
  15.     scroll(0, 0);
  16.     }
  17.      
  18.     function gobottom() {
  19.     scroll(0, document.body.scrollHeight);
  20.     }
  21.      
  22.     // HERE , the TWEAK : give "backtotop" name to the created element, for Styled "Back/To Top" ICONs on the left/Middle Side of the window
  23.      
  24.     var div = document.createElement("backTOtop"),
  25.     top = document.createElement("a"),
  26.     bottom = document.createElement("a");
  27.     div.setAttribute("style", "color: #000000; background: transparent; font-size: 12px; font-family: arial; display: block !important; position: fixed; bottom: 50%; right: -20px !important; padding: 3px; z-index: 99999; transform: rotate(90deg) !important;");
  28.     top.href = "javascript:void(0);";
  29.     bottom.href = "javascript:void(0);";
  30.     top.addEventListener("click", gotop, false);
  31.     bottom.addEventListener("click", gobottom, false);
  32.     top.setAttribute("style", " position: absolute!important; display: block !important; color:transparent!important; font: 0px arial;background:url(data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAB+SURBVDhPY1i1atV/amAGahgCMoNhaIGlS5cKAp19BoRBbLJcj2QILDJINwzoAmMgfoclIkBixkS5DI8hMJcRNgxoSBoOl6CnNZBhaVhdBjWE1MSJahjQkA4KEmYH2GUrV66cSYEhYB+AzKBtFiHkQqKiH6Ro1CDCQTWgYQQAs81DU0G/83sAAAAASUVORK5CYII=) no-repeat scroll 50% 50% rgba(0, 0, 0, 0.7); transform: rotate(270deg) !important; top: 24px !important; right: 43px !important; width: 6px!important; height: 20px!important; padding: 1px!important; ");
  33.     bottom.setAttribute("style", " position: absolute!important; display: block !important; color:transparent!important; font: 0px arial;background:url(data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAUCAYAAACAl21KAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAB+SURBVDhPY1i1atV/amAGahgCMoNhaIGlS5cKAp19BoRBbLJcj2QILDJINwzoAmMgfoclIkBixkS5DI8hMJcRNgxoSBoOl6CnNZBhaVhdBjWE1MSJahjQkA4KEmYH2GUrV66cSYEhYB+AzKBtFiHkQqKiH6Ro1CDCQTWgYQQAs81DU0G/83sAAAAASUVORK5CYII=) no-repeat scroll 50% 50% rgba(0, 0, 0, 0.7); transform: rotate(90deg) !important;; top: 24px !important; right: 1px !important; width: 8px!important; height: 21px!important; ");
  34.     top.textContent = " .... ";
  35.     bottom.textContent = "....";
  36.     div.appendChild(document.createTextNode(". "));
  37.     div.appendChild(top);
  38.     div.appendChild(document.createTextNode(" "));
  39.     div.appendChild(bottom);
  40.     document.body.appendChild(div);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement