Created
November 6, 2016 00:01
-
-
Save anonymous/b775351b7f5aa72e0f19d5061d81b11c to your computer and use it in GitHub Desktop.
(。>﹏<。)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name you counter | |
// @namespace ben | |
// @include https://boards.4chan.org/* | |
// @include http://boards.4chan.org/* | |
// @version 1 | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// @grant GM_addStyle | |
// @require http://code.jquery.com/jquery-1.9.1.js | |
// @require http://code.jquery.com/ui/1.10.3/jquery-ui.js | |
// ==/UserScript== | |
adder = null; | |
remover = null; | |
allTimeYou = GM_getValue("totalYou",null); | |
function count(){ | |
num = $('.you').length; | |
console.log('counting'); | |
console.log(num); | |
return num | |
} | |
function write(input){ | |
if (adder != null){ | |
if (adder != 0){ | |
storage(); | |
} | |
} | |
} | |
function difference(){ | |
var here = count(); | |
if (adder != null){ | |
remover = (here - adder) | |
adder = (here - adder) + adder; | |
console.log('new value ' + adder); | |
} | |
else{ | |
adder = here | |
console.log('starting adder'); | |
} | |
} | |
function render(){ | |
difference(); | |
write(adder); | |
console.log(allTimeYou); | |
} | |
function storage(){ | |
var store = GM_getValue("youHashTable",null); | |
if (store == null){ | |
store = {}; | |
store[window.location.href] = adder | |
} | |
else{ | |
if (store[window.location.href] != 0){ | |
store[window.location.href] = store[window.location.href] + remover} | |
else{ | |
store[window.location.href] = adder | |
} | |
} | |
GM_setValue('youHashTable',store); | |
console.log(store) | |
var total = 0 | |
for (var property in store){ | |
total += store[property]; | |
} | |
allTimeYou = total | |
GM_setValue('totalYou',allTimeYou); | |
} | |
var newHTML = document.createElement ('div'); | |
newHTML.innerHTML = ' \ | |
<div id="gmYouCounter"> \ | |
<p>"Total You Count:" </p> \ | |
</div> \ | |
'; | |
document.body.appendChild (newHTML); | |
document.getElementById("gmYouCounter").innerHTML="(You) Count: " + allTimeYou; | |
GM_addStyle ( " \ | |
#gmYouCounter { \ | |
position: fixed; \ | |
background-color: #1b1b1b; \ | |
color: #cccaca; \ | |
top: 5px; \ | |
right: 5px; \ | |
font-size: 16px; \ | |
} \ | |
" ); | |
setInterval (render,30000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment