Last active
May 30, 2018 23:45
-
-
Save J2TEAM/cf6f7910042aa221a89b to your computer and use it in GitHub Desktop.
Get a random post by using Blogger Feeds API.
This file contains hidden or 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
function getRandomPost(t){var o=t.feed.entry,n=o[Math.floor(Math.random()*o.length)];window.top.location.href=n.link[4].href}function loadScript(t){var o,n=document.getElementsByTagName("script")[0];o=document.createElement("script"),o.src=t,n.parentNode.insertBefore(o,n)}function randomButtonHandle(){var t=window.top.location,o=t.protocol+"//"+t.hostname+"/feeds/posts/default?alt=json-in-script&max-results=100&callback=getRandomPost";loadScript(o)}randomButtonHandle(); |
This file contains hidden or 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
! function(t, o) { | |
"use strict"; | |
t.getRandomPost = function(o) { | |
var n = o.feed.entry, | |
e = n[Math.floor(Math.random() * n.length)]; | |
t.top.location.href = e.link[4].href | |
}, o(document).ready(function(o) { | |
var n = t.top.location, | |
e = n.protocol + "//" + n.hostname + "/feeds/posts/default?alt=json-in-script&max-results=100&callback=getRandomPost"; | |
o("body").append('<script src="' + e + '"></script>') | |
}) | |
}(window, jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment