Run Chrome Extensions using command prompt

故事扮演 提交于 2020-01-01 05:16:14

问题


Is it possible to run a chrome extension from command line? I need to automate the process for my software, and my software will need to run that extension with a particular parameter.

I am using a Chrome Extension 'APK Downloader' by Yogi. The Extension works like this:- "If a page contains any .apk file link, then when I click on the extension's icon on the address bar, it starts direct download of that .apk file"

Now, I have my software that needs some .apk file to download [The software will have the package name of the .apk file to be downloaded, which is used by the extension to generate a download link]. It will be an automatic process. So, I need to know if it is possible to pass a parameter to the extension automatically, and make the extension to work without clicking on it.

Is it possible to do so??


回答1:


Unpacked extension can be loaded using the --load-extension= flag.

What I usually do is chromium --user-data-dir=/tmp/someuniquedirname --load-extension=path/to/extension --no-first-run.

  • The --user-data-dir= flag is used to specify a non-default user data directory, to minimize conflicts between your existing browser profile and the test directory. You can omit this flag if you want to use your default user profile.
  • The --no-first-runflag prevents the first run UI from showing up (e.g. the bubble that explains how to use the omnibox, and a "Getting Started" page that opens in a new tab).

You can load multiple extensions by separating the paths by commas, e.g. chromium --load-extension=path/to/one/extension,path/to/another/extension.

I have published some shell scripts and a convenience extension to speed up (manual) testing of Chrome extensions. Take a look at https://github.com/Rob--W/extension-dev-tools/tree/master/chrome.




回答2:


on a mac:

osascript <<EOD
set theURL to "chrome://extensions/"
tell application "Google Chrome"
 if windows = {} then
  make new window
  set URL of (active tab of window 1) to theURL
 else
  make new tab at the end of window 1 with properties {URL:theURL}
 end if
 activate
end tell
EOD

Question answered here: https://superuser.com/a/979678



来源:https://stackoverflow.com/questions/22193369/run-chrome-extensions-using-command-prompt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!