I'm developing a Google Chrome Extension with InboxSDK that runs on Gmail. Now that the Gmail part is ready I want to expand to other websites with a subset of functionality that doesn't require InboxSDK nor Gmail features. My idea was to attempt to load InboxSDK (it checks for the supported origins) and if it doesn't load skip the Gmail features.
That being said I've run into a problem where an attempt to load InboxSDK's by calling InboxSDK.load(2, "app_id")
prints a message in console: InboxSDK: Unsupported origin https://stackoverflow.com
and stops executing any code beyond that point.
I don't need InboxSDK on origins other than Gmail.
Is it possible to run the same extension with InboxSDK on Gmail and without InboxSDK on other websites?
I'm providing a simple TypeScript code to illustrate this case:
import * as InboxSDK from "inboxsdk"
(async function main() {
console.log("This will print on all websites")
const sdk = await InboxSDK.load(2, "APP_ID")
console.log("This will not be printed if the InboxSDK load fails")
})()
A possible solution I see is to implement the same origin check as InboxSDK does. I'm looking for a better solution that doesn't require duplicating this InboxSDK functionality.