Chrest: healthier window and tab hygiene
Chrest is a CLI tool and Chrome extension that allow you to manage Chrome via
REST. Chrest was inspired by (and somewhat forked from)
TabFS
.
Chrest consists of two parts:
- Chrome Extension: (/extension)
- Native Messaging Host & CLI Client:
chrest
(/)
Note: to keep Chrest slim, Chrest does not include pretty-print JSON or HTTP
Request construction, but there are other wonderful tools you can use for that
like http
and jq
.
-
Getting all windows and tabs:
$ http --ignore-stdin --offline localhost/windows | $ chrest client | $ jq > [ > { > "alwaysOnTop": false, > "focused": false, > "height": 1400, > "id": 1531273373, > "incognito": false, > "left": 1411, > "state": "normal", > "tabs": [ > { > "active": true, > "audible": false, > "autoDiscardable": true, > "discarded": false, > "favIconUrl": "https://github.githubassets.com/favicons/favicon.svg", > "groupId": -1, > "height": 1279, > "highlighted": true, > "id": 1531273367, > "incognito": false, > "index": 0, > "mutedInfo": { > "muted": false > }, > "pinned": false, > "selected": true, > "status": "complete", > "title": "friedenberg/chrest", > "url": "https://github.com/friedenberg/chrest", > "width": 1128, > "windowId": 1531273373 > } > ], > "top": 20, > "type": "normal", > "width": 1128 > } > ]
-
Creating a new window with some URL's:
$ http --ignore-stdin --offline localhost/windows \ $ urls[]=https://github.com/friedenberg/chrest | $ chrest client | $ jq > { > "alwaysOnTop": false, > "focused": false, > "height": 1400, > "id": 1531273390, > "incognito": false, > "left": 0, > "state": "normal", > "tabs": [ > { > "active": true, > "audible": false, > "autoDiscardable": true, > "discarded": false, > "groupId": -1, > "height": 1279, > "highlighted": true, > "id": 1531273391, > "incognito": false, > "index": 0, > "lastAccessed": 1708099951989.452, > "mutedInfo": { > "muted": false > }, > "pendingUrl": "https://github.com/friedenberg/chrest", > "pinned": false, > "selected": true, > "status": "loading", > "title": "", > "url": "", > "width": 1128, > "windowId": 1531273390 > } > ], > "top": 0, > "type": "normal", > "width": 1128 > }
-
Closing a window:
$ http --ignore-stdin --offline DELETE localhost/windows/1531273390 | $ chrest client | $ jq
-
Clone this repo:
git clone github.com/friedenberg/chrest
-
Go to Chrome extensions
-
Enable Developer mode (top-right corner)
-
Load-unpacked the
extension/
folder from this repoTake note of the extension ID, it looks like
lbgclgjcapgipnneocphmhckebhbbkac
-
go build
-
./chrest install <extension ID>
-
Add
$HOME/.local/bin
to your$PATH
-
Reload the extension in Chrome to start the service worker
-
Try
http --ignore-stdin --offline localhost/windows | ./chrest client | jq
example:
# fish shell
go build -o chrest cmd/main.go; and ./chrest install lbgclgjcapgipnneocphmhckebhbbkac
- mutate bookmark endpoints
- proper
PUT
endpoints for windows and tabs - history endpoints
- Chrome will turn off service workers when there are no windows left, so at
least 1 window needs to exist for
chrest
to be running. I may add a fallback inchrest
to useAppleScript
to create a new window if the server is not running.