Mac 命令行安装Chrome插件
2013-08-27 17:16
393 查看
1. 在终端调用命令行实现Chrome插件安装
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-easy-off-store-extension-install extensionPath
其中extensionPath是指的插件文件路径(Chrome插件文件的后缀名是crx),例如~/Desktop/chromeExtension.crx
注意:安装插件之前要确保Chrome浏览器不在运行
2. 通过代码实现Chrome插件安装
- (void)startInstallChromeExtension { NSURL *url = [[NSWorkspace sharedWorkspace] URLForApplicationWithBundleIdentifier:@"com.google.Chrome"]; if (url) { NSString *chromeExtensionPath = [[NSBundle mainBundle] pathForResource:EXTENSIONSOURCENAME ofType:@"crx" inDirectory:EXTENSIONDIRNAME]; NSDictionary *configuration = [NSDictionary dictionaryWithObjectsAndKeys: [NSArray arrayWithObjects:@"--enable-easy-off-store-extension-install",chromeExtensionPath,nil],NSWorkspaceLaunchConfigurationArguments, nil]; [[NSWorkspace sharedWorkspace] launchApplicationAtURL:url options:NSWorkspaceLaunchDefault configuration:configuration error:nil]; } } - (IBAction)installChromeExtension:(id)sender { NSArray *runningChromes = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.google.Chrome"]; if ([runningChromes count] > 0) { NSAlert * alert = [NSAlert alertWithMessageText:NSLocalizedString(@"安装Chrome插件,需要关闭正在运行的Chrome浏览器,是否允许?", @"") defaultButton:NSLocalizedString(@"OK", @"") alternateButton:NSLocalizedString(@"Cancel", @"") otherButton:nil informativeTextWithFormat:@""]; NSInteger result = [alert runModal]; if (result == NSAlertDefaultReturn ) { for (int i = 0; i < [runningChromes count]; i++) { [(NSRunningApplication *)[runningChromes objectAtIndex:i] forceTerminate]; } [self performSelector:@selector(startInstallChromeExtension) withObject:nil afterDelay:0.5]; } } else { [self performSelector:@selector(startInstallChromeExtension) withObject:nil afterDelay:0.5]; } }
相关文章推荐
- Mac 命令行安装Chrome插件
- mac本 chrome jsonView插件安装实用教程
- MAC OS X 命令行工具Terminal实用插件oh-my-zsh官方说明与安装引导
- Mac下Chrome的插件安装目录在哪?
- 离线Chrome插件安装文件(crx)的安装方法
- mac命令行安装htop
- 如何离线安装chrome插件【转】
- 谷歌浏览器中安装.crx扩展名的离线Chrome插件
- Mac及Windows系统下 eclipse neon安装svn插件遇见的问题及其解决方案
- chrome导出插件和安装.crx插件
- 怎么在谷歌浏览器中安装.crx扩展名的离线Chrome插件
- mac 10.12下安装Python3和eclipse安装Python插件
- mac 系统中vim安装ctags插件
- Mac下使用命令行安装 jenkins 方法
- 在谷歌浏览器中安装.crx扩展名的离线Chrome插件
- Chrome translate plugins install 谷歌翻译插件安装
- chrome的插件Postman安装方法
- chrome jsonView插件安装
- mac 命令行自动安装软件
- mac 命令行安装软件