0

There's a class called "original-image", which are img elements. I want to know how to save the src value of ALL of the "original-image" class elements locally.

This is the code:

<img title="Pirate Queen" alt="Pirate Queen" class="original-image " src="http://t0.rbxcdn.com/cfe7e313ed7cd57f5e39c7c4aad18683">

I'm trying to save the src of this element onto my hard drive, but for all of the elements of the "original-image" class on the page. How do I do this?

  • You can't force a download with JavaScript. [Read more here](http://stackoverflow.com/questions/6796974/force-download-an-image-using-javascript). – FWDekker Jul 22 '15 at 19:53

1 Answers1

1

Be happy with your hacking and buy my a beer....

We are going to use "download" attribute from html5 and make an autoclick, image by image

$(".original-image").each(function(){
    //Current image tag
    $this = $(this);
    //Current url
    $current_url = $this.attr('src');
    //Dynamic anchor
    $shadow_anchor = $('<a id="super_shadow_anchor" download href=' + $current_url +'></a>');
    $('body').append($shadow_anchor);

    setTimeout(function(){
        //Native click, jquery's click do not work 
        $("#super_shadow_anchor").get(0).click();
        //remove the anchor`enter code here`
        $("#super_shadow_anchor").remove();
    }, 500);

});

Edit: try it in HTML5 browser