1

I want to build a chrome extension that will search 30 different things up on the same tab. I tried the location.replace method and the _self method but nothing happened. However, when I tried window.open, it did work. This only opens a new window once, but I want it to open multiple times. How would I do this?

This is my code so far (arr is an array with some words):

function sleep(milliseconds) {
  const date = Date.now();
  let currentDate = null;
  do {
    currentDate = Date.now();
  } while (currentDate - date < milliseconds);
}
for(var i = 0; i<30; i++) {
  window.open('https://www.bing.com/search?q='+arr[Math.floor(Math.random() * arr.length)]);
  sleep (1000);
}
saa938
  • 11
  • 1

1 Answers1

0

You can do it giving a different name to each one:

window.open(url, `${Math.random()}`);

Window.open()

ManuelMB
  • 1,254
  • 2
  • 8
  • 16