nicolas-graves / ibrowse.el

Interact with your browser from Emacs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ibrowse

Ibrowse stands for interactive browse, its goal is to be able to control your web browser through common actions, be it on browser tabs, history or bookmarks using Emacs.

It relies on the completing-read built-in interface, and thus benefits grealty from integration with consult, marginalia, vertico and embark. Development constraints I’ll try to respect are to avoid javascript or the need for any additional browser extension (try to rely on native options instead). For supported functionality and comparison with similar packages, check-out below (c is for Chromium, f for Firefox, * means the implementation is not fully functional) :

packageupdatedtabbookmarkhistory
helm-chrome2016c(json)
helm-chrome-history2019c(sql*)
helm-chrome-control2019c(mac/osa+js)
chrome.el2021c(cdp)
counsel-chrome-bm2021c(json)
counsel-ffdata2019f(sql*)f(sql*)
helm-firefox2022f(html)
spookfox2023c,f(ws*)
global-interactive-emacs2023c(mac/osa)c(json)c(sql*)
ibrowse.el2023c(cdp), f(cdp*)c(json+radix), f(sql*)c,f(sql*)

Please note that the depth of actions is not comparable, much more actions are available in this package, see below. PR are welcome for other browsers/protocols/functionalities!

It is composed of three control functionalities for your browser :

ibrowse-tab.el

To use the functions in ibrowse-tab.el, you need to use the Chromium Developer Protocol. Simply run your browser with the option --remote-debugging-port=9222.

The Firefox CDP implementation is not complete, and action ibrowse-tab-select is only available in Chromium.

This subpackage will migrate to a Webdriver BiDi implementation once available in stable released web browsers.

This file currently introduces the following commands :

  • ibrowse-tab-select
  • ibrowse-tab-close
  • ibrowse-tab-copy-url
  • ibrowse-tab-insert-link

Copying url title is a native embark option.

ibrowse-history.el

This file has a dependency on ibrowse-sql.el, which itself depends on sqlite3.

Warning about SQL : Actions on SQL databases can’t work with an open browser (Chromium and Firefox lock their databases). ibrowse-history will record the command you want to execute on the database in ibrowse-sql-queue, and retry the command every ibrowse-sql-retry-interval seconds. If trying to close emacs without ibrowse-sql-queue empty, you will be prompted for a confirmation. Close the browser before Emacs for the commands to be applied.

This file will introduce the following commands :

  • ibrowse-history-delete
  • ibrowse-history-browse-url
  • ibrowse-history-copy-url
  • ibrowse-history-insert-link

ibrowse-bookmark.el

For Firefox, this file has a dependency on ibrowse-sql.el, the warning above about SQL applies as well.

This file will introduce the following commands :

  • ibrowse-bookmark-delete
  • ibrowse-bookmark-add
  • ibrowse-bookmark-browse-url
  • ibrowse-bookmark-copy-url
  • ibrowse-bookmark-insert-link

Embark functionalities

If you have embark installed, all actions for tabs, bookmark or history items can be swapped with another one (Actually… and But first… embark-act functionality, see this blog post).

Embark also allows to act on multiple entries as one (you can simply use embark actions to open several tabs or delete several history items at once).

Changelog

  • TODO : Implement Nyxt and Emacs’ browsers interaction:
    • [ ] Nyxt : Iff it makes sense, see nyxt.el.
    • [ ] EWW (wanted, but I won’t do it myself).
    • emacs-webkit (unsupported, security reasons).
  • WAIT : Migrate ibrowse-tab to Webdriver BiDi when available in stable packages web-platform-tests dashboard.
    • Add actions to print or screenshot a page.
  • WAIT : Improve implementation of SQL based on the built-in Emacs SQL support. For this, we would need the built-in Emacs SQL support to handle open the file with immutability=1. See bug#65274.
  • TODO : Proper testing in different environments would greatly help.
  • 0.2.3: Context-rich insert-link. Action management replaced by completing-read where possible.
  • 0.2.1 to 0.2.2: Various packaging fixes.
  • 0.2.0: Better file independence. Better SQL use. Better browser switch. Handle locked databases situation (queue + timer). Less file copies. Remove emacsql dependency. Split ibrowse-bookmark.
  • 0.1.9: Implement Firefox history and bookmark commands. Better SQL implementation. Handle browser switch.
  • 0.1.1 to 0.1.8: Various packaging fixes.
  • 0.1.0: Initial release for inclusion in Guix and Melpa.

Inspiration

This package is originally inspired by the Rofi Switch Browser Tabs scripts and the biblio.el package, but aspires to have broader functionalities, more integrated with Emacs. While writing the package, I also stumbled upon other packages, shown in the above table. All implement very close features to ibrowse, but are either more developped (chrome.el has a major mode frontend, which I considered unnecessary for a daily use with embark and the minibuffer), rely on helm or javascript code, or have more limited functionality. I occasionnally copied snippets of code from some of these packages, but gave credit to authors in copyrights and only copied GPLv3+ code, making this package an “aggregate” also under GPLv3+.

About

Interact with your browser from Emacs

License:GNU General Public License v3.0


Languages

Language:Emacs Lisp 100.0%