aprzn123 / TheThirdCan

A browser extension designed to improve https://twocansandstring.com
MIT License
7 stars 4 forks source link

question: script scoping #19

Closed HumanoidSandvichDispenser closed 1 year ago

HumanoidSandvichDispenser commented 1 year ago

Currently, injected scripts run on the global scope, which means that multiple scripts with the same variable names on a single page can conflict. It also messes up LSPs when they find a similarly named variable from a different script that may not be injected.

The way I avoided this in #3 was to wrap everything necessary in its own scope with curly braces.

Would this be a good way to avoid variable name conflicts? Is it a good idea to do this for every other script?

aprzn123 commented 1 year ago

I think that's probably a good way of dealing with that, although not a hugely important change (ideally each script is re-declaring the relevant variables anyway).

HumanoidSandvichDispenser commented 1 year ago

Closing in favor of #22