Inspiration

Firefox in OSX does allow you to go truly "full" screen - the navigation bar, bookmarks bar are still visible. There are many scripts which run without our knowledge which track us, show us advertisement and in some cases even mine crypto coins. Hack browser is an attempt to get our browser back- to customize and control each and every detail of our web browser.

Hack browser is inspired by Emacs where in user customization code runs at same privilege level as the application code itself. Like Emacs, it has a Lisp (ClojureScript) interpreter embedded in itself. The code for browser is written in ClojureScript which is in turn executed by the same interpreter. This gives Hack browser the power to change everything about itself dynamically.

Hack browser can also be used by companies to automate testing and profiling of websites programmatically.

What it does

Hack browser gives you a console which pops up like "Developer tools" in Chrome. You can type in ClojureScript in this console which will be evaluated by interpreter which interpreted the code for browser itself.

Using this console you can customize everything:

  • looks of the browser (chrome): which tool bars are shown, how keyboard bindings are made
  • how requests are made: filtering and blocking of incoming and outgoing requests
  • how cookies are handled
  • tracing resource consumption of browser: measure and log bandwidth, time taken to load
  • access to file system using nodejs: inside the console you have access to nodejs object using which you can have access to file system, execute shell commands (imagine piping the contents of your web blog to grep and then piping to wc) and electron object which gives access to all Chrome APIs.

How I built it

I used Electronjs to render the web pages and ClojureScript (Lisp) to build API wrapper around it, CodeMirror to build the console which highlights syntax and aids in editing by highlighting matching brackets.

Challenges I ran into

Dynamically loading and interpreting browser ClojureScript code was a big challenge which I haven't completely solved: eval function in ClojureScript require state in which the expressions must be evaluated. This state must be passed to every expression executed by user on console. Now the browser code itself must also be evaluated using eval to collect the state so that subsequent user expressions can be evaluated in the same state.

This, my guess is, will require use of Clojure reader (clojure.tools.reader) to read Clojure code from file and then converting it to Clojure code and then passed to eval. Currently I'm reading file as string as passing to eval

Accomplishments that I'm proud of

A working Lisp interpreter inside browser

What I learned

ClojureScript and Electronjs - this is my first project using these two things.

What's next for hack-browser

More APIs so that user can control more things from console easily. Reading ~/hack_browser.cljs similar to ~/.emacsd

Built With

Share this project:

Updates