You are using jQuery for something that can be done in native javascript.
document.querySelectorAll works with selectors mainly as jQuery does. It does not return an array, but an (in my opinion) unwieldy NodeList.
To get it to iterate properly, I prefer to spread it into an array and then call forEach on it.
[...document.querySelectorAll('.foo')].forEach((element, index) => {
console.log(element.innerText);
});
<div class="foo">bar</div>
<div class="foo">baz</div>
<div class="foo">bal</div>
Also, the method of getting the data is diffent currently.
On all the images you need to trigger a click first.
This will activate javascript event handlers that will set the href of the image grandparent.
You need let the google event handlers run first, so we detach the rest of our execution flow so the google script can do it's thing and update the DOM. We do this with setTimeout().
Then when the google scripts have run, the DOM elements have been updated, our scheduled timeouts get a chance to run, and now the href's have been populated.
Before the click the link looks like this:

after click

we now see that the href has been populated. The url that has been entered is:
https://www.google.com/imgres?imgurl=https%3A%2F%2Fwww.researchgate.net%2Fprofile%2FJerome_Droniou%2Fpublication%2F305983658%2Ffigure%2Ffig5%2FAS%3A668650201690119%401536430039650%2FMesh-patterns-for-the-tests-using-the-HMM-method-left-Test-1-right-Test-2.png&imgrefurl=https%3A%2F%2Fwww.researchgate.net%2Ffigure%2FMesh-patterns-for-the-tests-using-the-HMM-method-left-Test-1-right-Test-2_fig5_305983658&tbnid=_UuLNMPCQAT0uM&vet=12ahUKEwjhsu31zcnoAhWbgKQKHR3jAdUQMygAegUIARDTAQ..i&docid=LThLi5REXoitfM&w=428&h=428&q=hmm%20test&ved=2ahUKEwjhsu31zcnoAhWbgKQKHR3jAdUQMygAegUIARDTAQ
In this url we see after imgurl= something starting with https. This is our target image url, but it has been urlencoded and is part of a larger url.
So we manipulate the string with some simple substring manipulation.
Then we still have strange characters
https%3A%2F%2Fwww.researchgate.net%2Fprofile%2FJerome_Droniou%2Fpublication%2F305983658%2Ffigure%2Ffig5%2FAS%3A668650201690119%401536430039650%2FMesh-patterns-for-the-tests-using-the-HMM-method-left-Test-1-right-Test-2.png
for that we can use decodeURIComponent() to transform it into a normal url
document.write(decodeURIComponent('https%3A%2F%2Fwww.researchgate.net%2Fprofile%2FJerome_Droniou%2Fpublication%2F305983658%2Ffigure%2Ffig5%2FAS%3A668650201690119%401536430039650%2FMesh-patterns-for-the-tests-using-the-HMM-method-left-Test-1-right-Test-2.png'))
We then add this to our array.
When we've handled everything, we create the urls file and download it.
var urls = [];
var count = 0;
[...document.querySelectorAll('.rg_i')].forEach((element, index) => {
let el = element.parentElement.parentElement;
el.click();
count++;
setTimeout(() => {
let google_url = el.href;
let start = google_url.indexOf('=' , google_url.indexOf('imgurl'))+1;
let encoded = google_url.substring(start, google_url.indexOf('&', start));
let url = decodeURIComponent(encoded);
urls.push(url);
console.log(count);
if(--count == 0) {
let textToSave = urls.join('\n');
let hiddenElement = document.createElement('a');
hiddenElement.href = 'data:attachment/text,' + encodeURI(textToSave);
hiddenElement.target = '_blank';
hiddenElement.download = 'urls.txt';
hiddenElement.click();
}
}, 50);
});