Author

Topic: BitcoinTalk Unread Post AutoUpdate (Read 693 times)

legendary
Activity: 2088
Merit: 1015
August 29, 2013, 12:25:22 PM
#2
Code:
$page[42].children[2].children[0].children[0].children[0].children[0].children[0].children[1].children[2].innerHTML
You weren't kidding when you said ugly code Wink
hero member
Activity: 784
Merit: 1000
Casper - A failed entrepenuer who looks like Zhou
August 29, 2013, 10:19:51 AM
#1
Made a snippet for the Unread Post since last visit page to auto update itself without all the refresh, ugly code Tongue

At least it updates and you can catch up the latest news!

Code:
var script = document.createElement('script');
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
script.onload = function() {
setTimeout('confirminit()',1000)
};
function confirminit(){
$('#bodyarea').prepend('
Press to start autoupdates (12 seconds interval)
')

}
var audioElement = document.createElement('audio'); audioElement.setAttribute('src', 'http://chromaticcreative.net/bitcoin/p.mp3')
var $page
var iaa=0
function ajaxinit(){
iaa++
if(iaa>50){
$('#bodyarea').prepend('

Timeout, press to reconnect updates
');return false;
}
$.get(location.href, function(data) {
  $page = $(data);
if($('#bodyarea table.bordercolor table.bordercolor tr:nth-child(2) td:nth-child(3)').html()!=$page[42].children[2].children[0].children[0].children[0].children[0].children[0].children[1].children[2].innerHTML){
audioElement .play()
}
$('#bodyarea').html($page[42].innerHTML)
setTimeout('ajaxinit();$(".catbg span").text("Bitcoin Forum")',12000)
setTimeout('$(".catbg span").text("Until Next Update: 5")',7000)
setTimeout('$(".catbg span").text("Until Next Update: 4")',8000)
setTimeout('$(".catbg span").text("Until Next Update: 3")',9000)
setTimeout('$(".catbg span").text("Until Next Update: 2")',10000)
setTimeout('$(".catbg span").text("Until Next Update: 1")',11000)

});
}
Jump to: