document.querySelectorWorkers have no access to the DOM or document, so document.querySelector doesn't exist there.fetch, setTimeout and IndexedDB are tempting wrong answers, because people think workers can do very little. In fact, workers can use fetch, timers, IndexedDB and many other APIs. To change the page, the worker sends its results back with postMessage, and the page updates the DOM.
Read more