Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Inside of the head tags
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
- //Put this wherever you want the on/offline images to be
- <a src="http://twitch.tv/casy_nuf">
- <img id="nm" src="http://i.imgur.com/xNCtOBk.png"> //This image is the default, I suggest offline
- </a>
- //Just before the closing body tag (</body>)
- <script>
- ur = 'https://api.twitch.tv/kraken/streams/casy_nuf';
- $.ajax({
- url: ur,
- dataType: 'jsonp',
- type: 'get',
- success: function(data) {
- if(data.stream === null) {
- document.getElementById("nm").src='http://i.imgur.com/xNCtOBk.png'; //offline image
- } else {
- document.getElementById("nm").src='http://i.imgur.com/JU80pML.png'; //online image
- }
- },
- });
- </script>
Add Comment
Please, Sign In to add comment