I am currently trying to download images with an automated process to a specific folder in the directory using JavaScript or anything that can be integrated into a chrome extension so it can be handled by another program.
Target: The image I attached has the highlighted section of the image tag I am trying to download but so far I only found a way to download it into local storage as a test.
This is the code I am currently using for my tests to see if I can target it and put it in local storage.
// Get a reference to the image element
var captchaImg = document.getElementById("captchaImg");
// Take action when the image has loaded
captchaImg.addEventListener("load", function () {
var imgCanvas = document.createElement("canvas"),
imgContext = imgCanvas.getContext("2d");
// Make sure canvas is as big as the picture
imgCanvas.width = captchaImg.width;
imgCanvas.height = captchaImg.height;
// Draw image into canvas element
imgContext.drawImage(captchaImg, 0, 0, captchaImg.width, captchaImg.height);
// Get canvas contents as a data URL
var imgAsDataURL = imgCanvas.toDataURL("image/png");
// Save image into localStorage
try {
localStorage.setItem("captchaImg", imgAsDataURL);
}
catch (e) {
console.log("Storage failed: " + e);
}
}, false);
My plans for the chrome extension is too write the manifest and all the rest once I know what permissions are needed and such from the final scripts used to download and handle the image.
Goals:
Download the image to the hard drive
Download the image to a specific folder
Have the download automated
The code to be executed from a chrome extension