prasmussen / chrome-cli Goto Github PK
View Code? Open in Web Editor NEWControl Google Chrome from the command line
License: MIT License
Control Google Chrome from the command line
License: MIT License
because i use Canary for development
Hi! I'm wondering the meaning of the number (inside square brackets) before tabs/windows names when I run chrome-cli list tabs/chrome-cli list windows
. Like this:
[416:429] Wrapify Is A Startup Paying Drivers To Wrap Their Car In Ads | TechCrunch
[416:431] 5 Books That Explain the Evolution of the English Language - Grammarly Blog | Grammarly Blog
[416:433] When chemical cues disappear, ants rely on memory | Science | AAAS
[435:438] The Number Of College Students Seeking Mental Health Treatment Is Growing Rapidly
[435:440] Robots can now defend themselves against our flying kicks - Quartz
or this:
[292] Why Growth Mindsets Are Necessary to Save Math Class - The Atlantic
[357] Star Wars Galaxies and The Matrix Online: When Video-Game Worlds End - The Atlantic
[372] This Millennial Might Be the New Einstein | Rising Stars | OZY
[377] The Video Game Helmet That Can Hack Your Brain | Motherboard
[382] Thync - Wikipedia, the free encyclopedia
Trying to launch new chrome instance with 'chrome-cli open' works fine, but it spews error message.
Trying to open new chrome tab on chrome instance without any tab open doesn't work and just dump the same error message like 1).
2014-02-16 10:57:12.978 chrome-cli[3136:507] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '* -[SBProxyByClass setURL:]: object has not been added to a container yet; selector not recognized [self = 0x7fa1ea869180]'
Activating a tab does activate it, but it will leave the window in the background if that's where it was. While there might be a case for that, it seems more likely that the window should be brought to the foreground. As an alternative, maybe this could be a separate command.
Bonus points if it can also switch desktop spaces on Mac OSX.
Maybe it seems like the example below
chrome-cli tabs #list all tabs
chrome-cli window -c TABID #close the specific window
chrome-cli tabs -a TABID #active the specific tab
I am going to submit this to the Arch Linux AUR. Can you provide a link to a MD5 or SHA1 version of the latest release for integrity checks?
Not sure if this is possible, but could we print a page in the tab by saving it to a pdf file?, Currently I can "Save as PDF" in the chrome print dialog, I want to save this exact version (with the formatting applied by chrome) to a PDF file.
Would be super useful if possible!
Having the ability to reload custom extensions or apps, would make the workflow so much better.
For example, I'm using yeoman's chrome extension generator that comes with a grunt build task. The task builds and packages the extension, but I have to deploy it manually every time.
$ chrome-cli info
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[SBProxyByCode activeTab]: object has not been added to a container yet; selector not recognized [self = 0x7fdb1bc08280]'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff32767571 __exceptionPreprocess + 256
1 libobjc.A.dylib 0x00007fff5e718efb objc_exception_throw + 48
2 CoreFoundation 0x00007fff327673a3 +[NSException raise:format:] + 193
3 CoreFoundation 0x00007fff327067fe ___forwarding___ + 1468
4 CoreFoundation 0x00007fff327061b8 _CF_forwarding_prep_0 + 120
5 chrome-cli 0x000000010245f846 -[App activeTab] + 48
6 chrome-cli 0x000000010245f44e -[App printSourceFromActiveTab:] + 20
7 chrome-cli 0x0000000102460d3b -[Handler call:] + 416
8 chrome-cli 0x0000000102460361 -[Argonaut run] + 85
9 chrome-cli 0x000000010246141b main + 1449
10 libdyld.dylib 0x00007fff5f7df085 start + 1
11 ??? 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
most command+control commands fail with this error
chrome-cli list
commands exit with no output
I'm experiencing following abnormal termination, but everything except the error message seems to be fine.
mbp:Downloads deif$ chrome-cli execute '1'
2014-02-15 23:38:08.011 chrome-cli[593:507] -[**NSCFNumber UTF8String]: unrecognized selector sent to instance 0x127
2014-02-15 23:38:08.012 chrome-cli[593:507] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber UTF8String]: unrecognized selector sent to instance 0x127'
* First throw call stack:
(
0 CoreFoundation 0x00007fff8b08f41c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff891b5e75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8b0922ed -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff8afed5b2 __forwarding + 1010
4 CoreFoundation 0x00007fff8afed138 _CF_forwarding_prep_0 + 120
5 chrome-cli 0x000000010a6b59ee -[App executeJavascriptInActiveTab:] + 142
6 chrome-cli 0x000000010a6b6b62 -[Handler call:] + 401
7 chrome-cli 0x000000010a6b64cb -[Argonaut parse] + 511
8 chrome-cli 0x000000010a6b7176 main + 1244
9 libdyld.dylib 0x00007fff8a98d5fd start + 1
Is it possible to use this to open a new tab that's pinned?
Thanks for your tool.
Any project of compiling one version for windows ?
I can see that it's there in the applescript dictionary (as mode) so I presume this is possible.
My use case is that I have links that shouldn't be opened incognito, as they use authentication I only have in my 'normal' windows. So I want to script around those to get the best possible 'normal' window - using the active window if possible, or find a window to activate, or open a new window as a last resort.
Without being able to detect this, opening new windows each time is the only option.
e.g. activate tabs, replay XHR, print to the console, etc. (awesome project!)
Is it possible to make the output of chrome-cli list windows
to include the user names? I use multiple users on chrome to keep my work links and browsing separate from my personal and I'd like to be able to open a url from the command line in a specific window.
Current output of chrome-cli list windows
:
[24] New Issue · prasmussen/chrome-cli
[515] ☾ Alfred App - Productivity App for Mac OS X
Or are the window id's persistent across sessions?
Do you think it would be possible to add a feature to move/rearrange tabs between windows? And also move an existing tab to a new window.
Something like
chrome-cli move -t <id> -w <id>
and chrome-cli move -t <id>
respectively?
Is support for this possible?
Feature request: Anyway to add something like;
chrome-cli window resize w h
chrome-cli tab -t ID resize w h
??
It would be nice if people can install this by just brew install chrome-cli
.
chrome-cli open google.com
results in a new tab with "about:blank" in the title bar.
chrome-cli open www.google.com
also does exactly the same.
but chrome-cli open http://google.com
or chrome-cli open http://www.google.com
works as expected.
Can you make it so that the http:// protocol is optional? If we need a different protocol we can type that in instead.
Thanks
Hello @prasmussen. Thanks for the great cli!
Is it possible to activate a specific window based on its ID? The cli command list doesn't show anything as far as I can tell.
If you have an undocked devtools window, and use the reload
command, the HTML in the devtools window will reload, but not the actual page attached to it. I'm not sure if this is a limitation of the Chrome APIs. If you use the GUI, pressing Command+R in the detached devtools reloads the page.
eg:
chrome-cli --json info
should dump as jsonchrome-cli --json open http://www.google.com
same thingthis makes for reliable scripting (analog to git's porcelain vs plumbing mode) that won't break in case output adds new fields etc
Is it possible to support profile switching?
Thanks a lot for this project- it looks deadly awesome.
If you can support linux as well, you will have my eternal gratitude (and of many others as well).
I got an error in the console of Google Chrome
Uncaught ReferenceError: $ is not defined
when I executed the following command
chrome-cli execute '$(".tableData a").click();' -t 532
But if I input this javascript fragment into console, everything works fine.
I tried to sleep for a while before executing to avoid not loading jQuery, but the problem remains.
Thanks for your awesome work!
I've written the Teaspoon project, and if this project supports a relatively simple way to pipe console messages or run a script in a timeout -- waiting until that script is complete, we could add a chrome driver, much like phantomjs, or selenium webdriver.
If this is something that seems possible I'd be happy to add a Teaspoon driver for it.
Would love windows support for this...
as-is
$ chrome-cli open file:$(pwd)/README.adoc
to-be
~/repo $ chrome-cli open-file README.adoc # run file:$(pwd)/README.adoc
Id: 756
Title:
Url: file:///Users/user/repo/README.adoc
Loading: Yes
~/repo $ chrome-cli open-file ./README.adoc # run file:$(pwd)/README.adoc
Id: 757
Title:
Url: file:///Users/user/repo/README.adoc
Loading: Yes
~/repo $ chrome-cli open-file /Users/user/repo2/README.adoc
Id: 758
Title:
Url: file:///Users/user/repo2/README.adoc
Loading: Yes
Would be awesome.
I'am experiencing some unexpected termination with presentation mode.
My environment.
$ chrome-cli version
1.5.0
$ chrome-cli chrome version
58.0.3029.33
Errors with presentation mode.
$ chrome-cli list tabs
[6852] prasmussen/chrome-cli: Control Google Chrome from the command line
$ chrome-cli presentation -t 6852
2017-04-05 10:17:15.131 chrome-cli[90427:7334739] -[GoogleChromeWindow enterPresentationMode]: unrecognized selector sent to instance 0x7fff0fcc2360
2017-04-05 10:17:15.145 chrome-cli[90427:7334739] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GoogleChromeWindow enterPresentationMode]: unrecognized selector sent to instance 0x7fff0fcc2360'
*** First throw call stack:
(
0 CoreFoundation 0x00007fffa87b0e7b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffbd39acad objc_exception_throw + 48
2 CoreFoundation 0x00007fffa8832cb4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00007fffa8722fb5 ___forwarding___ + 1061
4 CoreFoundation 0x00007fffa8722b08 _CF_forwarding_prep_0 + 120
5 chrome-cli 0x0000000100297845 -[App enterPresentationModeWithTab:] + 130
6 chrome-cli 0x0000000100299c0b -[Handler call:] + 443
7 chrome-cli 0x000000010029920b -[Argonaut run] + 85
8 chrome-cli 0x000000010029a34e main + 1548
9 libdyld.dylib 0x00007fffbdc7e255 start + 1
10 ??? 0x0000000000000004 0x0 + 4
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[1] 90427 abort chrome-cli presentation -t 6852
Info outputs a list of information. Definitely we can use awk etc. to extract the Title out, but it will be more convenient to have things like chrome-cli title
or chrome-cli info.title
to get specific information out.
not sure how feasible it would be (haven't looked at the source too much), but piping a javascript file to execute
would be extremely useful.
$ chome-cli execute < foo.js
vs
$ chrome-cli execute `cat foo.js`
To run the program on other systems (like Linux), makefiles should be added. The program should not be built with XCode itself, as this restricts development for Mac only.
Unfortunately, I myself have no idea about objective c and also not about Make. Therefore I cannot do this myself. If this is provided I will gladly take care of the CI/CD and the like.
Hi,
I have been using chrome Cleint for a long time, it is a great tool. I have noted a couple of days ago, it stopped working in new chrome version. I installed an older version of chrome and it started working. I thought of bringing this to your attention
Thanks!
I haven't updated chrome-cli since this last worked just fine, so perhaps it's a change in Chrome itself.
I'm running Version 69.0.3497.81 (Official Build) (64-bit) on High Sierra.
Here's what I get:
$ chrome-cli list tabs
[990718318] Untitled spreadsheet - Google Sheets
[990718323] Issues · prasmussen/chrome-cli
$ chrome-cli source
$ chrome-cli source -t 990718323
$
Just nothing. The last time this worked fine for me was the beginning of August and today is the first time I've used my script that relies on this since then.
I'm trying to build chrome-cli on Mac OSX 10.8.5 as i would to make a version for Chromium as there is one for Chrome Canary but i'm getting some errors.
If i do brew unpack chrome-cli; cd chrome-cli-1.5.0; xcodebuild
i get errors about no visible interface for SBElementArray
that declares the selector firstObject
.
Well I may be just missing something obvious but I can't do anything because all I ever get is "No matching handler found".
I'm on a Mac OS X 10.7.5, and Chrome: Google Chrome 34.0.1825.4 (Official Build 249291) dev
Will it be possible to open a page and wait for it to finish loading? It would be convenient in a script to do other things after the page is successfully loaded.
Example:
[sorokine:~] brew install tmux
[sorokine:~] tmux
[sorokine:~] $ chrome-cli list links
Waiting for chrome to start...
2019-06-17 11:11:02.805 chrome-cli[92274:18604346] Scripting Bridge could not launch application id com.google.Chrome.
2019-06-17 11:11:02.917 chrome-cli[92274:18604346] Scripting Bridge could not launch application id com.google.Chrome.
2019-06-17 11:11:03.027 chrome-cli[92274:18604346] Scripting Bridge could not launch application id com.google.Chrome.
...
Chrome did not start for 15 seconds
I'm using profiles for quite some time, and opening a link with a specified Chrome profile is still not possible as far as I know. That would be a fantastic feature.
Switching or opening profiles might be handy features also.
Is it possible to move between tabs?
Thanks for chrome-cli @prasmussen -- a great tool.
Would you please add a hook to info -t [id]
that indicates if that tab happens to be active in the window?
When I run chrome-cli (installed via brew, os 10.9.4) in a crontab like so:
@reboot /usr/local/bin/chrome-cli presentation
I've also tried launching and then trying to start presentation mode like so:
@reboot open /Applications/Google\ Chrome.app
@reboot sleep 30 && /usr/local/bin/chrome-cli presentation
But haven't had any luck. It opens Chrome but doesn't start presentation mode. Is there any output given if the command fails? Would love to figure out why this is happening.
Can this be done? Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.