I do not have much formal programming knowledge, I've never taken a course and all the projects I've done so far have been simple executions of code I've slapped together and hit until it worked. I think I will be able to code it on my own so I am mainly asking for logic/structure help here.
Here is the question: I want to make a chrome extension that will open page A, wait for it to completely load + 2 seconds, then redirect to page B, wait for it to completely load + 2 seconds, then redirect to page C, etc. The user will just go AFK while it runs. I expect this list to be a few hundred URLs long, how do I structure this so I don't have like 300 functions updating the URL property to the next URL?
The two ideas I have are
create tab as the selected tab with URL A
onLoad wait for 2 additional seconds then update URL A to URL B
onLoad wait for 2 additional seconds of URL B update URL B to URL C
Repeat for the rest of the URLs
and
have 'file' in extension folder with a list of all URLs
create tab as the selected tab
update URL to 1st URL in 'file'
onLoad wait for 2 additional seconds then update to 2nd URL in 'file'
onLoad wait for 2 additional seconds then update to 3rd URL in 'file'
Repeat for the rest of the URLs
I know javascript has some weird synchronous/async stuff with executing functions and time constraints, and I'm not totally sure how it works. I would be really grateful for some input on what I would need to do to make this code work or what approach would be a better practice.
Thank you!