1const link = document.createElement('a');
2link.id = 'someLink'; //give it an ID!
3link.href = 'https://example.com'; // Your URL
4
5//Add the link somewhere, an appendChild statement will do.
6//Then run this
7document.getElementById('someLink').click();