Yesterday, I wrote all of this, working javascript code https://github.com/igorlogius/gather-from-tabs/discussions/8
And I don't know a lick of javascript
I know other languages but that barely was needed. I just gave it plain language instructions and reported the errors until it worked.