Hi,
I’m trying to detect whether my Safari Web Extension is running in Safari or Safari Technology Preview. Is there a reliable way to do that?
I can get the executable path of the parent process using proc_pidpath()
. However, unlike Chrome or Firefox, Safari extensions run under /sbin/launchd
as the parent process, not the responsible process (browser’s binary). In this scenario, I need the executable path of the actual browser process, but I haven’t found a way to get it.
Also, Safari doesn’t implement the Web Extension API’s browser.runtime.getBrowserInfo()
, unlike Firefox.
I haven’t tested it yet, but I’m considering checking the user agent string, though I’m not sure how reliable that would be.
Use Case
Some users use my Safari extension as a web development tool and want to enable some features exclusively in Safari Technology Preview, while using other features only in standard Safari. If I could detect which browser is in use, I could provide the appropriate functionality for them.