Usually, the S Object name would be consistent on a page, so it should be safe to always refer to "s" (or whatever you have defined the object name as) in an extension.
If you're writing an extension that will be deployed on sites with several different s object names, you could do something like this:
Assume you have 3 s objects, but you don't know which one is in scope for this extension:
You could do something like:
var local_s = window.teal_s || window.s || window.trackingData;
This would give you a local reference to the "s" object, so long as 1 of the 3 object names is defined.
I'm not sure if this would help in your situation or not. Perhaps you can share some more details on what you're trying to achieve?
Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated