Skip to content

Commit

Permalink
Adding Reddit karma integration
Browse files Browse the repository at this point in the history
The Reddit servers are so incredibly slow and unreliable that they need
to use local storage to work properly.
  • Loading branch information
StardustGogeta committed Apr 19, 2016
1 parent 77c7933 commit d40988c
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ <h1>StardustGogeta</h1>
</div>
<div data-toggle="collapse" data-target="#ac3" class="click">Reddit</div>
<div id="ac3" class="collapse">
Reddit
My Reddit account is <a href='http://reddit.com/u/StardustGogeta'>here</a>.<br>
My link karma is <span id='karma1'></span> and my comment karma is <span id='karma2'></span>.
</div>
<div data-toggle="collapse" data-target="#ac4" class="click">StackOverflow</div>
<div id="ac4" class="collapse">
Expand All @@ -33,7 +34,11 @@ <h1>StardustGogeta</h1>
</div>
<div data-toggle="collapse" data-target="#ac5" class="click">Chess</div>
<div id="ac5" class="collapse">
My current Blitz rating is <span id='blitz'></span>.
My Chess.com account is located <a href='https://www.chess.com/member/StardustGogeta'>here</a>.<br>
My current Blitz rating is <span id='blitz'></span>.<br>
My current Bullet rating is <span id='bullet'></span>.<br>
My current Standard rating is <span id='standard'></span>.<br>
My current Tactics rating is <span id='tactics'></span>.<br>
</div>
<div data-toggle="collapse" data-target="#ac6" class="click">Steam</div>
<div id="ac6" class="collapse">
Expand All @@ -53,15 +58,42 @@ <h1>StardustGogeta</h1>
</body>
<script>
// Thanks so much to Yahoo's YQL for making clientside webscraping possible!
var yqlCall = function(data){
var rep = function(data){
var rep = data.query.results.div;
document.getElementById('SOrep').innerHTML = rep;
};
var chess = function(data){
var rating = data.query.results.div;
document.getElementById('blitz').innerHTML = rating[0];
document.getElementById('bullet').innerHTML = rating[1];
document.getElementById('standard').innerHTML = rating[2];
document.getElementById('tactics').innerHTML = rating[5];
};
var karma = function(data){
try
{
var pts = data.query.results.span;
document.getElementById('karma1').innerHTML = pts[0];
document.getElementById('karma2').innerHTML = pts[1];
localStorage.setItem('karma1',pts[0]);
localStorage.setItem('karma2',pts[1]);
}
catch(err)
{
if(localStorage.getItem('karma1'))
{
document.getElementById('karma1').innerHTML = 'about '+localStorage.getItem('karma1');
document.getElementById('karma2').innerHTML = 'about '+localStorage.getItem('karma2');
}
else
{
document.getElementById('karma1').innerHTML = 'above 630';
document.getElementById('karma2').innerHTML = 'above 300';
}
}
};
</script>
<script type='application/javascript' src="https://query.yahooapis.com/v1/public/yql?q=select%20content%20from%20html%20where%20url%3D'http%3A%2F%2Fstackoverflow.com%2Fusers%2F5732397%2Fstardustgogeta'%20and%20xpath%3D'%2F%2Fdiv%5B%40class%3D%22reputation%22%5D'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=yqlCall"></script>
<script type='application/javascript' src="https://query.yahooapis.com/v1/public/yql?q=select%20content%20from%20html%20where%20url%3D'http%3A%2F%2Fstackoverflow.com%2Fusers%2F5732397%2Fstardustgogeta'%20and%20xpath%3D'%2F%2Fdiv%5B%40class%3D%22reputation%22%5D'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=rep"></script>
<script type='application/javascript' src="https://query.yahooapis.com/v1/public/yql?q=select%20content%20from%20html%20where%20url%3D'https%3A%2F%2Fwww.chess.com%2Fmember%2FStardustGogeta'%20and%20xpath%3D'%2F%2Fdiv%5B%40class%3D%22right%22%5D'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=chess"></script>
<script type='application/javascript' src="https://query.yahooapis.com/v1/public/yql?q=select%20content%20from%20html%20where%20url%3D'http%3A%2F%2Freddit.com%2Fu%2FStardustGogeta'%20and%20xpath%3D'%2F%2Fdiv%5B%40class%3D%22titlebox%22%5D%2Fspan'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=karma"></script>
</html>

0 comments on commit d40988c

Please sign in to comment.