I have an image that I need to routinely copy/save. It is on a web page (specifically an extension, but essentially it's HTML) and it only shows when a dialog is shown.
I have created a script that opens the dialog, then I need to right-click and copy that image to clipboard). I have tried initiating a right click on the image by finding an element that will always follow the image, then move up by 50 pixels and fo the right click. This brings up the browser's context men, where I then do a Found image macro to find the 'Copy image' menu item.
It is VERY hit and miss. Barely ever works.
My preference would be to do this:
Open the dialog (this has to be done as the image is not in the DOM until the dialog is shown, dynamically injected)
Get the src attribute, and somehow save that image from there without having to bring up context menus, use Found IMage macro etc etc
This does run, but just so you know I am very comfortable with running scripts in browser (web developer in the past), and I use those a lot for DOM manipulation.
Now, this script takes the text content, but what I need is to copy one specific image. Using the browser context menu is flaky. I can easily identify the image src attribute, is I wondered if I can retrieve that src for the image, can I feed that to something else to then download/save the image file, perhaps?
This worked perfectly, thank you! No drama to save it to a named clipboard. I had a feeling that my approach was way more complex (and brittle) than it needed to be!
This is kinda related ... so I will bolt this one on too! My reason for saving the image in question is to record a snapshot of something, and at the same time I'd like to grab a snapshot of the related page's HTML. The Get URL macros has an option to save the web page HTML as text, and this is handy, but is there a way to get a web archive or 'Save as Web Page Complete' that does not involve opening a browser window, but instead to do it silently like with this Get URL?
I did try the web archive, but it did not save an archive as such (it was literally the source showing in the web page, as if the HTML were rendered inside
Not exactly – it can save the code it is able to obtain as text – but it's not an actual browser that can load dynamic content created by scripts when a web page renders.
There's a Unix executable webarchiver – but I haven't tested it for some time.