Proper technique to manage variables in injected scripts with those of unknown page scripts

I apologize for the basic level of this question. Could you explain or please point me to proper techniques for ensuring that variables in an injected script won’t interfere with those of an unknown page script and vice versa?

Thank you.

By default they won’t interfere, you have to explicitly opt-in to interfere. See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts#DOM_access and the links in that section.

Thank you. I got my self confused by having one script injected by the manifest and another through browser.tabs.executeScript(), and those two scripts could “see” each others variables. But neither one was a page script. Stupid of me.