Title: BitcoinTalk Unread Post AutoUpdate
Post by: 001sonkit on August 29, 2013, 03:19:51 PM
Made a snippet for the Unread Post since last visit page to auto update itself without all the refresh, ugly code :P At least it updates and you can catch up the latest news! 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('<br><center><a href="#" style="font-size:16px" onclick="iaa=0;ajaxinit()">Press to start autoupdates (12 seconds interval)</a><br></center>')
} 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('<br><br><center><a href="#" style="font-size:16px" onclick="iaa=0;ajaxinit()">Timeout, press to reconnect updates</a><br></center>');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)
}); }
Title: Re: BitcoinTalk Unread Post AutoUpdate
Post by: bitspill on August 29, 2013, 05:25:22 PM
$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 ;)
|