NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Rentry scroll buttons // @namespace http://tampermonkey.net/ // @version 1.1 // @description Fixed scroll to top and bottom buttons & edit and export button to the top // @author Kuroi_Mato_O // @license MIT // @match https://rentry.org/* // @icon https://www.google.com/s2/favicons?sz=64&domain=rentry.org // @grant none // ==/UserScript== (function() { 'use strict'; //create arrow buttons var s = 'position: fixed; z-index: 9999; border: none; background: #262626; transform: scale(1.5);' ; var upButton = document.createElement("button"); upButton.innerHTML = "↑"; upButton.style = `top: 130px; ${s}`; var downButton = document.createElement("button"); downButton.innerHTML = "↓"; downButton.style = `top: 180px; ${s}`; const parent = document.querySelector(".container"); parent.appendChild(upButton); parent.appendChild(downButton); downButton.style.right = parent.offsetWidth + parent.offsetLeft + 5 + "px"; upButton.style.right = parent.offsetWidth + parent.offsetLeft + 5 + "px"; //edit and export buttons var miscButtons = document.getElementsByClassName("text-left")[0]; var m = 'position: fixed; top:19px; transform:scale(1.3); display: flex; flex-direction: column-reverse; align-items: stretch;' ; if (miscButtons){ miscButtons.style = `${m}`; miscButtons.style.right = parent.offsetWidth + parent.offsetLeft + 3 + "px"; } //scroll function upButton.addEventListener("click", function() { var textTab = document.getElementsByClassName("CodeMirror-scroll")[0]; var previewTab = document.getElementsByClassName("markdownx-preview")[0]; if (textTab || previewTab) { textTab.scrollTop = 0; previewTab.scrollTop = 0; } else { window.scrollTo(0, 0); } }); downButton.addEventListener("click", function() { var textTab = document.getElementsByClassName("CodeMirror-scroll")[0]; var previewTab = document.getElementsByClassName("markdownx-preview")[0]; if (textTab || previewTab) { textTab.scrollTop = textTab.scrollHeight; previewTab.scrollTop = previewTab.scrollHeight; } else { window.scrollTo(0, document.body.scrollHeight); } });})();