Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to get command line parameters in Google Chrome extension?

I need to launch Chrome from command line with custom parameter, which contains path to some js-file. Further this path will be used in extension.

I browsed carefully all related documentation and clicked all nodes in Chrome debugger, but found nothing which can resemble on command line parameters. Is it possible anyway to get these parameters or it's need to write more complex npapi-extension? (theoretically in such npapi- extension we able to get self process through win-api, command line of self process and so on).

like image 662
MontyBurns Avatar asked Jan 04 '12 11:01

MontyBurns


2 Answers

Hack alert: this post suggests passing a fake URL to open that has all the command-line parameters as query string parameters, e.g.,

chrome.exe http://fakeurl.com/?param1=val1&param2=val2
like image 172
dfrankow Avatar answered Sep 22 '22 08:09

dfrankow


Perhaps pass the path to your extension in a custom user agent string set via the command line. For example:

chrome.exe --user-agent='Chrome 43. My path is:/path/to/file'

Then, in your extension:

var path = navigator.userAgent.split(":");
console.log(path[1])
like image 43
Jimadine Avatar answered Sep 23 '22 08:09

Jimadine