Red Read Line

shows you how far you scrolled

  1. // ==UserScript==
  2. // @name Red Read Line
  3. // @namespace http://q-garden.de/greases
  4. // @description shows you how far you scrolled
  5. // @include http://*
  6. // @include https://*
  7. // @include ftp://*
  8. // @version 1
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. // load and execute from http://stackoverflow.com/q/6834930
  13. var load,
  14. execute,
  15. loadAndExecute;
  16. load = function (a, b, c) {
  17. var d;
  18. d = document.createElement('script'),
  19. d.setAttribute('src', a),
  20. b != null && d.addEventListener('load', b),
  21. c != null && d.addEventListener('error', c),
  22. document.body.appendChild(d);
  23. return d
  24. },
  25. execute = function (a) {
  26. var b,
  27. c;
  28. typeof a == 'function' ? b = '(' + a + ')();' : b = a,
  29. c = document.createElement('script'),
  30. c.textContent = b,
  31. document.body.appendChild(c);
  32. return c
  33. },
  34. loadAndExecute = function (a, b) {
  35. return load(a, function () {
  36. return execute(b)
  37. })
  38. };
  39. loadAndExecute('//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js', function () {
  40. $('body').append('<div id=\'redreadline\'></div>');
  41. var update;
  42. var scrollpos = 0;
  43.  
  44.  
  45. $(window).scroll(function () {
  46. $('#redreadline').css({"top":scrollpos, "opacity":"1"}).stop().clearQueue().fadeIn(0).fadeOut(500);
  47. clearTimeout(update);
  48. update = setTimeout(resetScroll, 300);
  49. });
  50. function resetScroll(){
  51. scrollpos = document.documentElement.scrollTop;
  52. //$('#redreadline').css({"top":scrollpos});
  53. }
  54. function addGlobalStyle(css) {
  55. var head,
  56. style;
  57. head = document.getElementsByTagName('head') [0];
  58. if (!head) {
  59. return;
  60. }
  61. style = document.createElement('style');
  62. style.type = 'text/css';
  63. style.innerHTML = css;
  64. head.appendChild(style);
  65. };
  66. addGlobalStyle('#redreadline{position: absolute; left:0; right:0; height:'+window.innerHeight+'px; width:100vw; margin:-3px; pointer-events:none; box-shadow: 0px 0px 15px 0px rgba(255, 0, 0, 1);opacity:0;}');
  67. });