TabFS: Mount your Browser Tabs as a Filesystem


TabFS is a browser extension that
mounts your browser tabs as a filesystem in your computer.

Out of the sphere, it supports Chrome and (to a lesser extent)
Firefox, on macOS and Linux.

Every of your originate tabs is mapped to a folder.


I undoubtedly delight in 3 tabs originate, and
they blueprint to some folders in TabFS

The recordsdata interior a tab’s folder right away specialize in (and would possibly well moreover set watch over) the
inform of that tab in your browser. (TODO: update as I add more)

Example: the url.txt, textual philosophize material.txt, and title.txt
recordsdata interior a tab’s folder, which repeat me these are living properties
for that tab

This gives you a ton of energy, because now that that you would possibly moreover observe your whole
serene instruments

in your computer that already know tips on how to manage with recordsdata — terminal
commands, scripting languages, and so forth — and verbalize them to govern and
talk with your browser.

Now you fabricate now not want to code up a browser extension from
scratch
each
time you desire to construct anything else. You are going to be ready to jot down a script that talks to
your browser in, adore, a melange of Python and bash, and it will build you
it as a single common
file
that you
can speed at any time when, and it is no varied from scripting any varied portion
of your computer.

table of contents

Examples of stuff that that you would possibly moreover construct!

(assuming your latest directory is the fs subdirectory of the git
repo and that you would possibly delight in gotten the extension working)

Checklist the titles of your whole tabs that you would possibly delight in gotten originate

$ cat mnt/tabs/by-identification/*/title.txt
GitHub
Extensions
TabFS/install.sh at master · osnr/TabFS
Alternative Extension Distribution Choices - Google Chrome
Web Store Web hosting and Updating - Google Chrome
Home / Twitter
...

Cull tabs adore each varied recordsdata

Deciding on and deleting a bunch of tabs in my file manager

I’m using Dired in Emacs here, nonetheless that that you would possibly verbalize whatever instruments you
already undoubtedly feel happy managing your recordsdata with.

End all Stack Overflow tabs

$ rm mnt/tabs/by-title/*Stack_Overflow

or (older / more explicit)

$ echo prefer away | tee -a mnt/tabs/by-title/*Stack_Overflow*/set watch over

btw

(this project, eradicating all tabs whose titles delight in some string, is a
tiny contrived, nonetheless it absolutely’s now not that unrealistic, correct?)

(now… how would you construct this without TabFS? I of direction fabricate now not delight in any
belief, off the discontinue of my head. adore, how construct you even safe the titles of
tabs? how construct you repeat the browser to cease them?)

(I looked up the APIs, and, OK, when you are already in a browser
extension, in a ‘background script’ within the extension, and your
extension has the tabs permission — this already requires you to
originate 2 separate recordsdata and hop between your browser and your textual philosophize material
editor to goal it all up! — that that you would possibly moreover construct
this:
chrome.tabs.search records from({}, tabs=> chrome.tabs.prefer away(tabs.filter(tab=>
tab.title.contains('Stack Overflow')).blueprint(tab=> tab.identification)))
)

(now not unpleasant, nonetheless search in any admire that upfront overhead to safe it goal
up. and it is now not all that discoverable. and what when you are going to adore to reuse
this later, or hotfoot it into some better pipeline of instruments in your
computer, or give it a visible interface? the soar in complexity once
it is miles a must always-want to talk with anything else — perchance constructing a
WebSocket, constructing handlers and a inform machine — is rather
horrifying)

(nonetheless to be perfect, I wouldn’t even delight in conceived of this as a thing I
would possibly well construct within the first region)

Keep textual philosophize material of all tabs to a file

$ cat mnt/tabs/by-identification/*/textual philosophize material.txt> textual philosophize material-of-all-tabs.txt

Lope script

$ echo 'doc.body.sort.background="green"'> mnt/tabs/remaining-centered/fabricate-script
$ echo 'alert("hi!")'> mnt/tabs/remaining-centered/fabricate-script

Reload an extension within the event you edit its supply code

Notify you are working on a Chrome extension (except for this
one). It is a anguish to reload the extension (and perchance affected Web
pages) at any time whenever you switch its code. There is a Stack Overflow
put up

with programs to automate this, nonetheless they’re all form of hacky. That that you would possibly perchance like
yet one other extension, or it is miles a must always-want to tack uncommon permissions onto your
work-in-progress extension, and you fabricate now not precise safe a expose that that you would possibly moreover
trigger out of your editor or shell to refresh the extension.

TabFS capability that you can construct all this in an common shell
script
.
You fabricate now not want to jot down any browser-side code in any admire.

This script turns an extension (this one’s title is “Playgroundize
DevTools Protocol”) off, then turns it reduction on, then reloads any tabs
which delight in the relevant pages originate (in this case, I sure it is tabs
whose titles starting up with “Chrome Dev”):

#!/bin/bash -eux
echo fallacious> mnt/extensions/Playg*/enabled
echo appropriate> mnt/extensions/Playg*/enabled
echo reload | tee mnt/tabs/by-title/Chrome_Dev*/set watch over

I mapped this script to Ctrl-. in my textual philosophize material editor, and now I precise hit
that at any time once I wish to reload my extension code.

TODO: Dwell edit a working Web page

edit page.html within the tab folder. I notify it would possibly perchance precise stomp
outerHTML first and predominant, within the destroy would possibly well construct one thing more sophisticated

(it would possibly perchance be frigid to delight in a chronic storage epic here
moreover. I adore the foundation of being ready to build aside arbitrary recordsdata wherever in
the subtree, undoubtedly, because you then would possibly well verbalize git and emacs
autosave and stuff without cost… hmm)

TODO: Peek expressions

$ contact mnt/tabs/remaining-centered/watches/window.scrollY

Now that that you would possibly moreover cat window.scrollY and specialize within the build aside you are scrolled on the
page at any time.

Might well maybe maybe originate an advert-hoc
dashboard

around a Web page: a bunch of terminal windows floating around your
tune, each sitting in a loop and using cat to video display a special
variable.

TODO: Import records (JSON? XLS? JS?)

recede a JSON file foo.json into the imports subfolder of the tab
and it exhibits up because the item imports.foo in JS. (adjust
imports.foo in JS and then read imports/foo.json and you read the
changes reduction?)

import a plotting library or regardless of the same capability? dragging
plotlib.js into imports/plotlib.js and then calling
imports.plotlib() to invoke that JS file

the browser has alternative likely energy as an interactive programming
environment, one the build aside graphics arrive as
naturally
as
console I/O construct in most programming languages. i notify one thing that
holds it reduction that is underexplored is incapacity to precise… recede
recordsdata in and efficiency up them with decent instruments. many Web-primarily based ‘IDEs’ delight in
to reinvent file management, and so forth from scratch, and it is adore a
separate universe from the remainder of your computer, and migrating
between one and the quite quite a bit of is an actual anguish (when you are going to adore to make verbalize of some
Python library to munge some records and then delight in a Web-primarily based
visualization of it, as an illustration, or when you are going to adore to model recordsdata
interior it, or originate snapshots so that you undoubtedly feel
happy

attempting stuff, and so forth).

(what would the chronic storage epic here be? localStorage? it is
attention-grabbing because I practically want each tab to be much less of a
commodity
,
much less
disposable,
since now it is miles the positioning I’m dragging stuff to and it would possibly perchance moreover delight in some
chronic inform connected. adore, if I’m programming and modifying stuff
and saving interior a tab’s folder, that tab out of the blue undoubtedly
issues; I
want it to continue to exist as lengthy as a customary file would, unlike most browser
tabs this day)

Setup

disclaimer: this extension is an experiment. I feel it is frigid and
precious and intriguing, and I generally lunge away it on, nonetheless I originate no
guarantees about efficiency or, in particular, safety. applications
would possibly well freeze, your browser would possibly well freeze, there would possibly well moreover very properly be programs for Websites
to make verbalize of the extension to flee and damage your computer … In some
sense, the entire
point
of this
extension is to originate a plentiful serene surface build aside of communication
between stuff interior your browser and tool on the remainder of your
computer.

Earlier than doing anything else, clone this repository:

$ git clone https://github.com/osnr/TabFS.git

First, install the browser extension.

Then, install the C filesystem.

1. Set up the browser extension

(I feel for Opera or whatever varied Chromium-primarily based browser, that that you would possibly
safe it to work, nonetheless you’ll deserve to interchange the native messaging direction in
install.sh. No longer sure about Safari. maybe Edge too? when you moreover got
all the pieces to bring together for Home windows)

in Chrome

Dawdle to the Chrome extensions page. Enable
Developer mode (high-correct corner).

Load-unpacked the extension/ folder in this repo.

Receive a display of the extension ID Chrome assigns. Mine is
jimpolemfaeckpjijgapgkmolankohgj. We will verbalize this later.

in Firefox

You are going to want to install as a “non eternal extension”, so it will simplest remaining
in your latest FF session. (TODO: is this fixable? signature stuff?)

Dawdle to about:debugging#/runtime/this-firefox.

Load Brief-term Add-on…

Purchase manifest.json within the extension subfolder of this repo.

2. Set up the C filesystem

First, originate sure that you would possibly delight in gotten FUSE and FUSE headers. On Linux, as an illustration,
sudo factual install libfuse-dev or identical. On macOS, safe FUSE for
macOS
.

Then bring together the C filesystem:

$ cd fs
$ mkdir mnt
$ originate

Now install the native messaging host into your browser, so the
extension can originate and check with the filesystem:

Chrome and Chromium

Change the extension ID you copied earlier for
jimpolemfaeckpjijgapgkmolankohgj within the expose under.

$ ./install.sh chrome jimpolemfaeckpjijgapgkmolankohgj

or

$ ./install.sh chromium jimpolemfaeckpjijgapgkmolankohgj

Firefox

$ ./install.sh firefox

3. Ready!

Return to chrome://extensions or
about:debugging#/runtime/this-firefox and reload the extension.

Now your browser tabs needs to be mounted in fs/mnt!

Delivery the background page inspector to be conscious of the filesystem operations
stream in. (in Chrome, click on “background page” next to “Rely on views”
within the extension’s entry within the Chrome extensions page; in Firefox,
click on “Rely on”)

This console is moreover incredibly indispensable for debugging anything else that
goes unsuitable, which potentially will happen. (When you safe a generic I/O
error at the shell when working a expose on TabFS, that potentially
manner that an exception took region which you are going to moreover check here.)

(My OS and applications are rather chatty. They construct alternative
operations, even once I fabricate now not undoubtedly feel adore I’m undoubtedly doing
anything else. My sense is that macOS is mostly chattier than Linux.)

Homicide

  • fs/: Native FUSE filesystem, written in C
    • tabfs.c:
      Talks to FUSE, implements fs operations, talks to extension. I
      rarely want to interchange this file; it of direction is precise a stub
      that forwards all the pieces to the browser extension.
  • extension/: Browser extension, written in JS
    • background.js:
      One of the most attention-grabbing file. Defines your whole artificial recordsdata and
      what browser operations they invoke at the reduction of the scenes.

My belief is that within the event you, as an illustration, cat
mnt/tabs/by-identification/6377/title.txt
within the tab filesystem:

  1. cat in your computer does a system name originate() down into macOS
    or Linux,

  2. macOS/Linux sees that this direction is portion of a FUSE filesystem, so it
    forwards the originate() to the FUSE kernel module,

  3. FUSE forwards it to the tabfs_open implementation in our
    userspace filesystem in fs/tabfs.c,

  4. then tabfs_open rephrases the search records from as a JSON string and
    forwards it to our browser extension over stdout (‘native
    messaging’
    ),

  5. our browser extension in extension/background.js gets the
    incoming message; it triggers the route for
    /tabs/by-identification/*/title.txt, which calls the browser extension API
    browser.tabs.safe to safe the records about tab ID 6377, together with
    its title,

  6. so when cat does read() later, the title can safe despatched reduction in
    a JSON native message to tabfs.c and finally reduction to FUSE and the
    kernel and cat.

(tiny or no proper work took region here, tbh. it is all precise
marshalling)

TODO: originate diagrams?

License

GPLv3

things that would possibly well/needs to be done

  • add more artificial recordsdata!! see DOM nodes, snapshot latest HTML of
    page, spelunk into living objects. specialize in what your code is doing. originate
    more recordsdata writable moreover

  • receive more (GUI and CLI) instruments on high, on either side

  • more persistence stuff. as I acknowledged earlier, it would possibly perchance moreover be frigid if
    that that you would possibly effect arbitrary recordsdata within the subtrees, so .git, Mac prolonged
    attrs, editor temp recordsdata, and so forth all work. originate it ready to behave adore
    a ‘proper’ filesystem. moreover as I acknowledged earlier, some weirdness within the
    reality that tabs are so disposable; they’ve a extremely varied
    lifecycle from most facets of my proper filesystem. tips on how to nudge that?

  • why can’t Preview originate photos? GUI programs in most cases battle with the
    filesystem for some reason. CLI more well-behaved

  • multithreading. the critical constraint is that I circulate -s to
    fuse_main in tabfs.c, which makes all the pieces
    single-threaded. nonetheless I’m undecided on how great it would possibly perchance reinforce
    efficiency? maybe quite a bit, nonetheless undecided. maybe workload-dependent?

    the extension itself (and the stdin/stdout comm between the fs and
    the extension) would composed be single-threaded, nonetheless that that you would possibly
    interleave requests since most of that stuff is async. adore the
    screenshot search records from that takes adore half of a 2d, that that you would possibly construct varied
    stuff while searching ahead to the browser to safe reduction to you on that (?)

    one other subject is that applications tend to dangle if any
    particular particular person search records from hangs anyway; they must always now not searching ahead to the
    filesystem to be so slow (and to be honest to them, they undoubtedly delight in
    no capability
    to). a majority of these considerations would possibly well moreover very properly be inevitable for any FUSE
    filesystem, even ones you are going to capture are reasonably battle-tested and
    properly-engineered adore sshfs?

  • varied efficiency stuff — remembering once we’re already connected
    to things, reference counting, minimizing browser roundtrips. now not
    sure impact of these

  • TypeScript (tips on how to construct with the minimal amount of receive system and
    equipment manager nonsense?)

  • search into reinforce for Firefox / Home windows / Safari / and so forth. handiest FUSE
    equiv for Home windows? are you able to bridge to the a ways-off debugging APIs that
    all of them already want to safe the augmented efficiency? or precise
    put in force it all with JS monkey patching?

  • window management. tab management the build aside that that you would possibly moreover switch tabs. ‘merge
    all windows’

hmm

  • Processes as Files
    (1984)
    ,
    Julia Evans /proc amusing lay out the
    fashioned /proc filesystem. it is completely frigid! very incandescent within the device in which it
    reapplies the serene interface of recordsdata to the serene arena of Unix
    processes. nonetheless how great construct I care about Unix processes now? most
    programs that
    I care about working on my computer within the intervening time are Websites, now not
    Unix
    processes
    . so
    I wish to prefer the approach of /proc — ‘repeat the stuff you care
    about as a filesystem’ — and observe it to one thing
    serene: the
    interior of the browser. ‘browser tabs as recordsdata’

  • there are two ‘operating systems’ on my computer, the browser and
    Unix, and Unix is by a ways the more accessible and programmable and
    cohesive as a computing environment (it has ideas that safe!
    shell, processes, recordsdata), even even though it is arguably the much less critical
    to my day-to-day lifestyles. how can the browser prefer on more of the properties
    of Unix?

  • it is capability too
    engaging
    to originate a
    browser extension. even ‘originate an extension’ is a noxious framing; it
    suggests making an extension is a total Thing, a total Mission. adore,
    why can’t I precise prefer a minute to ask my browser a quiz or repeat it
    to automate one thing? lightness

  • alternative serene uses of these browser set watch over APIs are in an
    automation context: sorting out your code on a robotic browser as portion
    of some pipeline. I’m a ways more attracted to an interactive,
    end-client context. augmenting the capability I verbalize my day to day
    browser. that is why this is an extension. it would now not require your
    browser to speed in some uncommon a ways-off debugging mode that you are going to continually
    overlook to flip on. it precise stays
    working

  • system name tracing (dtruss or
    strace) broad precious when anything else goes unsuitable. (want to disable
    SIP on macOS, although.) the combo of dtruss (application side)
    & console logging fs search records from/response (filesystem side) gives a broad
    amount of insight into basically any scenario, end to total

    • there is form of this sequence that I learned to try with
      anything else. first, both straightforward shell commands or pure C calls —
      shell commands are more ergonomic, C calls delight in the clearest
      mental model of what syscalls they undoubtedly invoke. simplest then construct
      you switch to the textual philosophize material editor or the Mac Finder, that are quite a bit
      fancier and throw a ways more stuff at the filesystem right away (so
      more can lunge unsuitable)
  • for alternative things within the extension API, the browser can remark you
    of updates nonetheless there would possibly be no obvious capability to search records from the corpulent latest
    inform. so we would possibly well well want to sit down down down in these create of areas from the
    starting and to find the incoming events to know, adore, the remainder
    time a tab became once updated, or the checklist of scripts currently working on
    a tab

  • async/wait for became once fully a must always-want to organising this readable

  • filesystem as ‘originate input house’ the build aside there are stuff that that you would possibly moreover tell
    past what this explicit filesystem cares about. (it reminds me
    of my Screenotate — screenshots give you
    this originate field the build aside that that you would possibly moreover carry
    by device of

    stuff that the OCR would now not primarily acknowledge or care about. associated
    for the proper world in Dynamicland; that that you would possibly moreover scribble notes or
    whatever even supposing the computer would now not specialize in them)

  • now that you would possibly delight in gotten this total ‘language’, this total toolset, to govern
    and automate your browser. there would possibly be this built-up serene capital
    the build aside heaps of americans and heaps of application tool and heaps of
    programming languages … already know the operations to work with
    recordsdata

  • this project is frigid bc i right away safe a dataset i care
    about
    . I
    found myself using it ‘authentically’ rather rapid — to sure out
    my tabs, to support me construct varied things within the browser so I would possibly well moreover delight in
    actions I would possibly well trigger from my editor, …

  • stuff that looks frigid / is expounded:

    • SQLite virtual tables
      delight in some of the same vitality as FUSE artificial filesystems to
      me, except for in region of ‘file operations’, ‘SQL’ is the properly-acknowledged
      interface / records rotten / ecosystem that they
      piggyback
      on. osquery appears
      portion

Read More

Similar Products:

Recent Content