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

3,601 views
Skip to first unread message

MontyBurns

unread,
Jan 4, 2012, 2:44:15 AM1/4/12
to Chromium-extensions
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).

Michael Gundlach

unread,
Jan 4, 2012, 10:33:42 AM1/4/12
to MontyBurns, Chromium-extensions
I'm not aware of a way to read command line params, but you can pass a URL to Chrome on the command line, and you can detect that URL being loaded.  So a hack would be to call chrome.exe http://fakeurl.com/?all-the-data-you-need-to-pass, and have your extension redirect this URL to the new tab page and then act according to the data in the querystring.

A hack for sure, but it might work.


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


Nathan Wray

unread,
Jan 4, 2012, 9:06:20 AM1/4/12
to chromium-...@chromium.org
We need this as well, we're launching the browser with a (unique, per-session) callback port on the command line that we need to access from an extension.  No solution so far.


On Wed, Jan 4, 2012 at 2:44 AM, MontyBurns <autor...@gmail.com> wrote:

Luke

unread,
Jan 5, 2012, 7:17:08 AM1/5/12
to Chromium-extensions
I think Michael solution is best you can achieve with no effort.
in example:
http://init.extension/session_port/2456/otherDataInSomeFormatInExampleBase64Encoded

and then you can run in your background.html a simple regexp on
chrome.tabs.onCreated listener then you initialize settings for such
URI and then redirect to start page, delete tab, or redirect
somewhere.
Settings will be avaiable for whole session (till browser close or
manual clean by extension). Few lines, 30 minutes of coding and
everything is working very well. Not to mention that URI format is
very clear, in my opinion far better than --some-option, and you can
even put binary data by URI using base64

On 4 Sty, 15:06, Nathan Wray <nw...@detroitsci.com> wrote:
> We need this as well, we're launching the browser with a (unique,
> per-session) callback port on the command line that we need to access from
> an extension.  No solution so far.
>
>
>
>
>
>
>
> On Wed, Jan 4, 2012 at 2:44 AM, MontyBurns <autorus...@gmail.com> wrote:
> > 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).
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Chromium-extensions" group.
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org.

MontyBurns

unread,
Jan 4, 2012, 5:03:22 PM1/4/12
to Chromium-extensions
Very interesting. Could you be so kind as to give a little bit more
detailed info?

On Jan 4, 6:06 pm, Nathan Wray <nw...@detroitsci.com> wrote:
> We need this as well, we're launching the browser with a (unique,
> per-session) callback port on the command line that we need to access from
> an extension.  No solution so far.
>
>
>
>
>
>
>
> On Wed, Jan 4, 2012 at 2:44 AM, MontyBurns <autorus...@gmail.com> wrote:
> > 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).
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Chromium-extensions" group.
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org.

Monty Burns

unread,
Jan 5, 2012, 7:32:00 AM1/5/12
to Chromium-extensions
Yep, it's good idea. It was the first I thought when this task
appeared. Probably I'll choose such variant. Anyway, thank u very much
for answers.

On Jan 5, 4:17 pm, Luke <lordde...@gmail.com> wrote:
> I think Michael solution is best you can achieve with no effort.
> in example:http://init.extension/session_port/2456/otherDataInSomeFormatInExampl...
Reply all
Reply to author
Forward
0 new messages