def attachIfSafari_(self, userInfo): if userInfo.get(u'NSApplicationBundleIdentifier') != SAFARI: return pid = userInfo['NSApplicationProcessIdentifier'] path = NSBundle.mainBundle().pathForResource_ofType_(u'IDNSnitchPlugin', u'plugin') if path is None: NSLog(u'Could not find plugin') return path = os.path.join(path, u'Contents', u'MacOS', u'IDNSnitchPlugin') NSLog(u'Injecting %s into Safari [%d]' % (path, pid)) objc.inject(pid, path.encode('utf-8')) self.statusText.setStringValue_(u'Injected into Safari [%d]' % (pid,))
import sys import os import objc if __name__ == '__main__': if len(sys.argv) < 2: raise SystemExit, "%s: You must specify the pid of a process to inject InjectBrowserPlugin into" % ( sys.argv[0], ) interp = os.path.abspath( 'dist/InjectBrowserPlugin.plugin/Contents/MacOS/InjectBrowserPlugin') if not os.path.exists(interp): if os.spawnl(os.P_WAIT, sys.executable, sys.executable, 'setup.py', 'py2app', '-A'): raise SystemExit, "Could not build InjectBrowserPlugin" objc.inject(int(sys.argv[1]), interp)
import sys import os import objc if __name__ == "__main__": if len(sys.argv) < 2: raise SystemExit, "%s: You must specify the pid of a process to inject InjectInterpreterPlugin into" % ( sys.argv[0], ) interp = os.path.abspath("dist/InjectInterpreterPlugin.plugin/Contents/MacOS/InjectInterpreterPlugin") if not os.path.exists(interp): if os.spawnl(os.P_WAIT, sys.executable, sys.executable, "setup.py", "py2app", "-A"): raise SystemExit, "Could not build InjectInterpreterPlugin" objc.inject(int(sys.argv[1]), interp)