Top

Add top button on every page.

  1. // ==UserScript==
  2. // @name Top
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Add top button on every page.
  6. // @author You
  7. // @match *://*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. var parent = document.createElement('div');
  14. var top = document.createElement('div');
  15. top.append('Top')
  16. top.onclick = function() {
  17. window.scrollTo(0, 0)
  18. }
  19. top.className = 'go-top'
  20. top.style.position = 'fixed';
  21. top.style.bottom = '20px';
  22. top.style.right = '20px';
  23. top.style.cursor = 'pointer';
  24. top.style.zIndex = '999';
  25. parent.append(top)
  26. document.body.append(parent);
  27. // Your code here...
  28. })();
  29.