Saturday, 23 April 2016

Recover images Snippet

As a side project for the archery club I'm a member of I've been looking at saving some stuff to Google Drive as a backup so I've been trawling the interweb for examples of how to upload backups weekly. I did find an old but interesting article but the images were broken :-(.

Then I got to thinking about how to recover them and clocked that the full size images which they linked to still existed so I cracked open Chrome's snippet pane and entered this as a new snippet:

Array.prototype.forEach.call(document.querySelectorAll(".no-line"), function(el, i){
    var img = el.querySelector("img");
    img.setAttribute("src", el.getAttribute("href"));
    img.setAttribute("width","100%");
});

This way of sorting stuff is just so unbelievably powerful and is probably why my codeivate score is as low as it is... Why bother with a full on IDE when you can do most, if not all, of your work in the browser - all without worrying that your changes will affect anyone else?

No comments:

Post a Comment