2020-10-28 04:53:39 +01:00
|
|
|
# TabFS
|
2019-02-26 05:13:58 +01:00
|
|
|
|
2020-10-30 09:00:09 +01:00
|
|
|
Mount your browser tabs as a filesystem!
|
2020-10-30 08:06:12 +01:00
|
|
|
|
2020-10-30 09:00:09 +01:00
|
|
|
<img src="doc/finder.png" width="500">
|
|
|
|
|
|
|
|
Each of your open tabs is mapped to a folder with a bunch of control
|
|
|
|
and live-updating content files inside it. (TODO: update as I add more)
|
|
|
|
|
|
|
|
<img src="doc/finder-contents.png" width="500">
|
|
|
|
|
|
|
|
This gives you a _ton_ of power, because now you can apply [all the
|
|
|
|
existing tools](https://twitter.com/rsnous/status/1018570020324962305)
|
|
|
|
on your computer that already know how to deal with files -- terminal
|
|
|
|
commands, scripting languages, etc -- and use them to control and draw
|
|
|
|
information from your browser. You don't need to write a browser
|
|
|
|
extension from scratch every time you want to do anything.
|
|
|
|
|
|
|
|
## Examples of stuff you can do!
|
2020-10-30 08:06:12 +01:00
|
|
|
|
2020-10-30 08:39:21 +01:00
|
|
|
(assuming your shell is in the `fs` subdirectory of this repo)
|
2020-10-30 08:06:12 +01:00
|
|
|
|
2020-10-30 09:00:09 +01:00
|
|
|
(TODO: more of these)
|
|
|
|
|
2020-10-30 08:06:12 +01:00
|
|
|
### List the titles of all the tabs you have open
|
|
|
|
|
|
|
|
```
|
|
|
|
$ cat mnt/tabs/by-id/*/title
|
|
|
|
GitHub
|
|
|
|
Extensions
|
|
|
|
TabFS/install.sh at master · osnr/TabFS
|
|
|
|
Alternative Extension Distribution Options - Google Chrome
|
|
|
|
Web Store Hosting and Updating - Google Chrome
|
|
|
|
Home / Twitter
|
|
|
|
...
|
|
|
|
```
|
|
|
|
|
|
|
|
### Close all Stack Overflow tabs
|
|
|
|
|
|
|
|
```
|
2020-11-06 04:09:44 +01:00
|
|
|
$ echo remove | tee -a mnt/tabs/by-title/*Stack_Overflow*/control
|
2020-10-30 08:06:12 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
### Save text of all tabs to a file
|
|
|
|
|
|
|
|
(wip, FIXME)
|
|
|
|
|
|
|
|
```
|
|
|
|
$ cat mnt/tabs/by-id/*/text > text.txt
|
|
|
|
```
|
|
|
|
|
2019-02-26 05:13:58 +01:00
|
|
|
## Setup
|
|
|
|
|
2020-10-30 07:54:40 +01:00
|
|
|
First, install the browser extension.
|
2019-02-26 05:13:58 +01:00
|
|
|
|
2020-10-30 07:54:40 +01:00
|
|
|
Then, install the C filesystem.
|
|
|
|
|
2020-10-30 08:39:21 +01:00
|
|
|
### 1. Install the browser extension
|
2020-10-30 07:54:40 +01:00
|
|
|
|
|
|
|
(I think it will work on Edge or Opera or whatever, too. You'll need to
|
|
|
|
change the native messaging path in install.sh in those cases.)
|
|
|
|
|
2020-10-30 08:39:21 +01:00
|
|
|
#### in Chrome
|
2020-10-30 07:54:40 +01:00
|
|
|
|
|
|
|
Go to the [Chrome extensions page](chrome://extensions). Enable
|
|
|
|
Developer mode (top-right corner).
|
|
|
|
|
|
|
|
Load-unpacked the `extension/` folder in this repo.
|
|
|
|
|
2020-10-30 08:06:12 +01:00
|
|
|
Make a note of the extension ID. Mine is
|
|
|
|
`jimpolemfaeckpjijgapgkmolankohgj`. We'll use this later.
|
2020-10-30 07:54:40 +01:00
|
|
|
|
2020-10-30 08:39:21 +01:00
|
|
|
#### in Firefox
|
2020-10-30 07:54:40 +01:00
|
|
|
|
2020-10-30 08:39:21 +01:00
|
|
|
You'll need to install as a "temporary extension", so it'll only last
|
|
|
|
in your current FF session.
|
2020-10-30 07:54:40 +01:00
|
|
|
|
2020-10-30 08:39:21 +01:00
|
|
|
Go to [about:debugging#/runtime/this-firefox](about:debugging#/runtime/this-firefox).
|
|
|
|
|
|
|
|
Load Temporary Add-on...
|
|
|
|
|
|
|
|
Choose manifest.json in the extension subfolder of this repo.
|
|
|
|
|
|
|
|
### 2. Install the C filesystem
|
2019-02-26 05:13:58 +01:00
|
|
|
|
2020-10-24 07:47:59 +02:00
|
|
|
First, make sure you `git submodule update --init` to get the
|
|
|
|
`fs/cJSON` and `fs/base64` dependencies.
|
|
|
|
|
|
|
|
And make sure you have FUSE. On Linux, for example, `sudo apt install
|
|
|
|
libfuse-dev`. On macOS, get FUSE for macOS.
|
2019-02-26 05:13:58 +01:00
|
|
|
|
|
|
|
```
|
|
|
|
$ cd fs
|
|
|
|
$ mkdir mnt
|
2020-10-24 07:47:59 +02:00
|
|
|
$ make
|
2019-02-26 05:13:58 +01:00
|
|
|
```
|
|
|
|
|
2020-10-28 04:53:39 +01:00
|
|
|
Now install the native messaging host into your browser, so the
|
|
|
|
extension can launch and talk to the filesystem:
|
|
|
|
|
2020-10-30 08:06:12 +01:00
|
|
|
#### Chrome and Chromium
|
|
|
|
|
|
|
|
Use the extension ID you copied earlier.
|
|
|
|
|
|
|
|
```
|
|
|
|
$ ./install.sh chrome jimpolemfaeckpjijgapgkmolankohgj
|
|
|
|
```
|
|
|
|
|
|
|
|
or
|
|
|
|
|
2020-10-28 04:53:39 +01:00
|
|
|
```
|
2020-10-30 08:06:12 +01:00
|
|
|
$ ./install.sh chromium jimpolemfaeckpjijgapgkmolankohgj
|
2020-10-28 04:53:39 +01:00
|
|
|
```
|
|
|
|
|
2020-10-30 08:39:21 +01:00
|
|
|
### 3. Ready!
|
2020-10-28 04:53:39 +01:00
|
|
|
|
2020-10-30 08:39:21 +01:00
|
|
|
Go back to `chrome://extensions` or
|
|
|
|
`about:debugging#/runtime/this-firefox` and reload the extension.
|
2020-10-28 04:53:39 +01:00
|
|
|
|
2020-10-30 07:54:40 +01:00
|
|
|
Now your browser tabs should be mounted in `fs/mnt`!
|
2020-10-28 04:53:39 +01:00
|
|
|
|
2020-10-30 08:39:21 +01:00
|
|
|
Open the background page inspector to see the filesystem operations
|
|
|
|
stream in. (in Chrome, click "background page" next to "Inspect views"
|
|
|
|
in the extension's entry in the Chrome extensions page; in Firefox,
|
|
|
|
click "Inspect")
|
2020-10-30 07:54:40 +01:00
|
|
|
|
2020-10-30 08:06:12 +01:00
|
|
|
<img src="doc/inspector.png" width="600">
|
2020-10-30 07:54:40 +01:00
|
|
|
|
2020-10-30 08:06:12 +01:00
|
|
|
This console is also incredibly helpful for debugging anything that
|
|
|
|
goes wrong, which probably will happen.
|
2020-10-30 07:54:40 +01:00
|
|
|
|
2020-10-30 08:06:12 +01:00
|
|
|
(My OS and applications are pretty chatty! They do a lot of
|
|
|
|
operations, even when I don't feel like I'm actually doing anything.)
|
2019-02-26 05:13:58 +01:00
|
|
|
|
|
|
|
## Design
|
|
|
|
|
|
|
|
- `extension/`: Browser extension, written in JS
|
2020-10-30 08:06:12 +01:00
|
|
|
- [`background.js`](extension/background.js): **The most interesting file**. Defines all the
|
|
|
|
synthetic files and what browser operations they map to.
|
2019-02-26 05:13:58 +01:00
|
|
|
- `fs/`: Native FUSE filesystem, written in C
|
2020-10-30 08:06:12 +01:00
|
|
|
- [`tabfs.c`](fs/tabfs.c): Talks to FUSE, implements fs operations, talks to extension.
|
2019-02-26 05:13:58 +01:00
|
|
|
|
2020-10-30 08:39:21 +01:00
|
|
|
<!-- TODO: concretize this -->
|
|
|
|
|
2019-02-26 05:13:58 +01:00
|
|
|
When you, say, `cat` a file in the tab filesystem:
|
|
|
|
|
|
|
|
1. `cat` makes something like a `read` syscall,
|
|
|
|
|
|
|
|
2. which goes to the FUSE kernel module which backs that filesystem,
|
|
|
|
|
|
|
|
3. FUSE forwards it to the `tabfs_read` implementation in our
|
|
|
|
userspace filesystem in `fs/tabfs.c`,
|
|
|
|
|
|
|
|
4. then `tabfs_read` rephrases the request as a JSON string and
|
2020-10-24 07:47:59 +02:00
|
|
|
forwards it to the browser extension over 'native messaging',
|
2019-02-26 05:13:58 +01:00
|
|
|
|
|
|
|
6. our browser extension in `extension/background.js` handles the
|
|
|
|
incoming message and calls the browser APIs to construct the data
|
|
|
|
for that synthetic file;
|
|
|
|
|
2020-10-24 07:47:59 +02:00
|
|
|
7. then the data gets sent back in a JSON native message to `tabfs.c`
|
|
|
|
and and finally back to FUSE and the kernel and `cat`.
|
2019-02-26 05:13:58 +01:00
|
|
|
|
|
|
|
(very little actual work happened here, tbh. it's all just
|
|
|
|
marshalling)
|
|
|
|
|
|
|
|
TODO: make diagrams?
|
2020-10-28 04:53:39 +01:00
|
|
|
|
2020-10-28 22:14:57 +01:00
|
|
|
## license
|
|
|
|
|
|
|
|
GPLv3
|
|
|
|
|
2020-10-28 04:53:39 +01:00
|
|
|
## hmm
|
|
|
|
|
|
|
|
it's way too hard to make an extension. even 'make an extension' is
|
|
|
|
a bad framing
|
|
|
|
|
|
|
|
open input space -- filesystem
|
|
|
|
|
|
|
|
now you have this whole 'language', this whole toolset, to control and
|
|
|
|
automate your browser
|
|
|
|
|
|
|
|
OSQuery
|
|
|
|
|
|
|
|
fake filesystems talk
|
|
|
|
|
|
|
|
Screenotate
|
|
|
|
|
|
|
|
processes as files. the real process is the browser.
|
|
|
|
|
|
|
|
browser and Unix
|
|
|
|
|
|
|
|
rmdir a non-empty directory
|