0
// ==UserScript==
// @name         Girl Picture
// @namespace    http://your.homepage/
// @version      0.1
// @description  enter something useful
// @author       You
// @match       http://api.huceo.com/meinv/?key=a3ea84353f84d820ce6e6c2e49e17d8a&num=1
// @require     http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js
// ==/UserScript==


$(document).ready(function(){

setInterval(function(){

    GM_xmlhttpRequest({
        method: "GET",
        url:"http://api.huceo.com/meinv/?key=a3ea84353f84d820ce6e6c2e49e17d8a&num=1",            
        overrideMimeType: "text/html; charset=GB2312", 
        onload: function(response) {

            var images = jQuery.parseJSON(response.responseText);

            var image = images[0].picUrl;

            document.write("<img src='"+image+"'><br>");                    

        }
    });

},5000);


});

the above Tampermonkey script is intended to parse a JSON data and retrieve the image url then display the images one after another every 5 seconds.

But it just only display 1 image and stop. I search everywhere but can not find why this happens.

Please kindly help debug. Thanks a lot!!

Yolo
  • 373
  • 1
  • 3
  • 8

0 Answers0