Advertisement
Guest User

You Counter

a guest
Sep 22nd, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Dragable Boxs
  3. // @namespace ben
  4. // @include https://boards.4chan.org/*
  5. // @include http://boards.4chan.org/*
  6. // @version 1
  7. // @grant GM_getValue
  8. // @grant GM_setValue
  9. // @grant GM_addStyle
  10. // @require http://code.jquery.com/jquery-1.9.1.js
  11. // @require http://code.jquery.com/ui/1.10.3/jquery-ui.js
  12. // ==/UserScript==
  13. $( ".dialog" ).draggable();
  14.  
  15. window.setTimeout(function(){
  16. $( ".dialog" ).draggable();
  17.  
  18. // $(".postContainer.replyContainer").draggable();
  19.  
  20. }, 1000);
  21.  
  22. adder = null;
  23. remover = null;
  24. allTimeYou = GM_getValue("totalYou",null);
  25.  
  26. function count(){
  27. num = $('.you').length;
  28. console.log('counting');
  29. console.log(num);
  30. return num
  31. }
  32. function write(input){
  33. if (adder != null){
  34. if (adder != 0){
  35. storage();
  36. }
  37. }
  38. }
  39.  
  40. function difference(){
  41. var here = count();
  42. if (adder != null){
  43. remover = (here - adder)
  44. adder = (here - adder) + adder;
  45. console.log('new value ' + adder);
  46. }
  47. else{
  48. adder = here
  49. console.log('starting adder');
  50. }
  51.  
  52. }
  53.  
  54. function render(){
  55. difference();
  56. write(adder);
  57. console.log(allTimeYou);
  58.  
  59. }
  60. function storage(){
  61. var store = GM_getValue("youHashTable",null);
  62. if (store == null){
  63. store = {};
  64. store[window.location.href] = adder
  65. }
  66. else{
  67. if (store[window.location.href] != 0){
  68. store[window.location.href] = store[window.location.href] + remover}
  69. else{
  70. store[window.location.href] = adder
  71. }
  72. }
  73. GM_setValue('youHashTable',store);
  74. console.log(store)
  75. var total = 0
  76. for (var property in store){
  77. total += store[property];
  78. }
  79. allTimeYou = total
  80. GM_setValue('totalYou',allTimeYou);
  81. }
  82.  
  83. var newHTML = document.createElement ('div');
  84. newHTML.innerHTML = ' \
  85. <div id="gmYouCounter"> \
  86. <p>"Total You Count:" </p> \
  87. </div> \
  88. ';
  89.  
  90. document.body.appendChild (newHTML);
  91. document.getElementById("gmYouCounter").innerHTML="All Time You Count: " + allTimeYou;
  92.  
  93. GM_addStyle ( " \
  94. #gmYouCounter { \
  95. position: fixed; \
  96. background-color: white; \
  97. color: red; \
  98. top: 0px; \
  99. left: 0px; \
  100. } \
  101. " );
  102.  
  103.  
  104.  
  105. setInterval (render,30000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement