Redirect Random Post Blogger

Script buat redirect random post blogger.
pastikan url yg digunakan bukan post alias page not found
script safelink nya terserah mau pake punya siapa tinggal disesuaikan

<b:if cond='data:blog.pageType == &quot;error_page&quot;'>
<script type='text/javascript'>
//<![CDATA[
function getToken() {
	var lokasi = document.location.pathname;
	var n = lokasi.search("download/") + 9;
	var pindah = lokasi.substr(n);
	return pindah;
}
function showLucky(root){
    var feed = root.feed;
    var entries = feed.entry || [];
    var entry = feed.entry[0];
      for (var j = 0; j < entry.link.length; ++j) {
       if (entry.link[j].rel == "alternate") {
       window.location = entry.link[j].href + '?token=' + getToken();
       }
      }
   }

function fetchLuck(luck){
    script = document.createElement('script');
    script.src = '/feeds/posts/summary?start-index='+luck+'&max-results=1&alt=json-in-script&callback=showLucky';
    script.type = 'text/javascript';
    document.getElementsByTagName('head')[0].appendChild(script);
   }
function readLucky(root){
    var feed = root.feed;
    var total = parseInt(feed.openSearch$totalResults.$t,10);
    var luckyNumber = Math.floor(Math.random()*total);
    luckyNumber++;
    fetchLuck(luckyNumber);
    }
function feelingLucky(){
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = '/feeds/posts/summary?max-results=0&alt=json-in-script&callback=readLucky';
    document.getElementsByTagName('head')[0].appendChild(script);
}

$(document).ready(function(){
var lokasi = document.location.pathname;
var n = lokasi.search("download/") + 9;
var pindah = lokasi.substr(n)
if (pindah.length > 11) feelingLucky();
});
//]]>
</script>
</b:if>
Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *