Back to Top figuccio

Add button to return top of each page.

目前为 2019-04-13 提交的版本。查看 最新版本

// ==UserScript==
// @name           Back to Top figuccio
// @author         figuccio
// @namespace https://greasyfork.org/users/237458
// @description    Add button to return top of each page.
// @version        0.3
// @include        *
// ==/UserScript==

// Create link to top.
function create_back_to_top() {
if(document.body){
	var a = document.createElement('span');
	a.innerHTML = "🡹";
	var c = "position:fixed;text-align:right;right:170px;bottom:2px;z-index:50000;";
	c+='color:red!important;background-color:green;border:2px solid blue;padding:6px 15px;font-size:11pt;cursor:pointer;font-weight:bold;text-decoration:none;border-top-right-radius:px;border-top-left-radius:px;box-shadow:0 0 6px rgba(0,0,0,.5);';

	a.style.cssText = c;
	a.addEventListener('mouseover', function(){ a.style.opacity = 1; }, false);
	a.addEventListener('mouseout', function(){ a.style.opacity = 1; }, false);
	a.addEventListener('click', function(){ window.scrollTo(0,0); }, false);
    a.addEventListener('click', function(){ a.style.color='white';
 setTimeout(function() { a.style.color='red' ;

    }, 2000);
  }, false);
document.body.appendChild(a);
	}
};

if(self==top) create_back_to_top();