Skip to content

ginqi7/auto-browser

Repository files navigation

Auto Browser

Overview

There are many exciting online services, and I hope to access them using Emacs.

Auto Browser is a bridge between Emacs and the browser, allowing control of the browser and quick access to web pages.

It only supports Chromium-based browsers because it relies on remote-debugging-port.

Auto Browser provides some simple APIs to control the browser and access pages and elements on a page. You can see the API reference here.

Prerequisites

  • Chromium-based browsers: Your daily browser.
  • Python : 3.6 and above

Require Packages

  • websocket-bridge: A bridge that connects Emacs and Python programs via WebSocket.
  • shr : To render html.

Install

Dependent Packages

  • clone the project in your own emacs configuration files directory, like:
    git clone git@github.com:ginqi7/auto-browser.git ~/.emacs.d/lisp/auto-browser
    git clone git@github.com:ginqi7/websocket-bridge.git ~/.emacs.d/lisp/websocket-bridge
    git clone git@github.com:ahyatt/emacs-websocket.git ~/.emacs.d/lisp/emacs-websocket
        

The emacs-websocket can be downloaded from ELPA.

  • add the path to ‘load-path’
    (add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp/d/lisp/auto-browser"))
    (add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp/d/lisp/auto-browser/plugins"))
    (add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp/websocket-bridge"))
    (add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp/emacs-websocket"))
        

Install Python dependencies

It is recommended to create a dedicated Python environment for auto-browser, so it does not interfere with the regular Python environment, for example:

  1. python3 -m venv auto-browser
  2. /SOME_PATH/auto-browser/bin/pip3 install sexpdata websocket_bridge_python DrissionPage readability-lxml lxml_html_clean

Reuse existing browser instance

Run Chrome with –remote-debugging-port=9222

"/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" --remote-debugging-port=9222

Configuration

Here are a few variables that can be used for configuration:

(require 'auto-browser)
;; Different plugins, different packages introduced
(require 'web-ai)
(require 'anki)
(require 'miniflux)
(require 'telegram)
(require 'twitter)
(require 'console)

(setq auto-browser-python "~/auto-browser/bin/python3") ;; Specify the path of the python command you are using.
(setq auto-browser-miniflux-base-url "http://127.0.0.1") ;; The address of Miniflux you are using
;; You can define shortcut access keys through transient
(transient-define-prefix prefix-auto-browser ()
  "Prefix for auto browser."
  ["Command"
   ("a" "Anki" auto-browser-anki-study)
   ("w" "Web AI" auto-browser-web-ai-input)
   ("m" "Miniflux" auto-browser-miniflux-open-unread)
   ("t" "Telegram" auto-browser-telegram-list-dialogues)
   ("x" "Twitter" auto-browser-twitter-following)
   ("c" "console" auto-browser-console-org-send)])

;; Bind a shortcut key.
(keymap-global-set "C-c a" #'prefix-auto-browser)
;; start auto-browser
(auto-browser-restart)

Detailed Descriptions of Each Plugin

Problem Diagnosis

When encountering issues during use, you can call websocket-bridge-app-log-buffer to view the problem log of auto-browser.

Examples

Anki

examples/anki.gif

Miniflux

examples/miniflux.gif

Web AI

examples/ai.gif

About

An Emacs plugin for controlling the browser and accessing web pages.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published