with Chrome manifest 3, if you need Dom or any unsupported web APIs on Background (e.g. the service worker), you have to go through the offscreen permission :
https://developer.chrome.com/docs/extensions/reference/api/offscreen#availability
Otherwise switch to Content script side yeah.