← Lab Notes
August 8, 2026 homelabchrome-extensionautomation

Starting: Action Repeater (browser extension)

A Chrome browser extension that records and replays user actions for automation tasks.


Overview

I've been working on a personal project to build a simple yet versatile browser extension called "Action Repeater." This tool allows users to record sequences of clicks and form-field changes, then replay them either once, multiple times, or in an infinite loop. The primary use case is automating repetitive tasks like daily logins and button clicks on internal work tools.

Background

The idea for this project came from a need at my workplace where I had to perform the same daily login and a few button clicks on an internal tool that only allowed one action per day. To make this process more efficient, I decided to build a browser extension that could handle these tasks automatically.

How It Works

Approach

The extension consists of three main components: content.js, popup.html/popup.js/popup.css, and background.js.

  1. Content Script (content.js):

    • Injected on every page, this script listens for user actions (clicks and form-field changes) while recording them.
    • It generates a CSS selector for each target element and stores the action list in chrome.storage.local. This ensures that the recorded sequence survives page navigation. The script re-attaches to the page if storage indicates an active session.
  2. Popup UI (popup.html/popup.js/popup.css):

    • Provides a user interface for recording, playing back, and managing macros.
    • Allows users to name and start/stops recordings, list saved macros, set repeat counts (0 for infinite loops), and configure delays between loops. It also includes an inline schedule row with a checkbox and time picker to run the macro daily at a fixed time.
  3. Background Script (background.js):

    • Implements MV3 service worker support for scheduling tasks.
    • Uses chrome.alarms to trigger scheduled macros, focusing the correct tab and sending the necessary messages to replay the recorded actions.

Key Features

  • Checkpoint Mechanism: A "Mark checkpoint" button during recording allows users to handle manual verification steps (like face verification) by pausing the playback until a specific element appears.
  • Daily Scheduling: Macros can be scheduled to run daily at a fixed time, ensuring they are executed even if the browser is not open.

Security Considerations

  • Password Handling: Password fields are recorded in plaintext within chrome.storage.local. While this storage is sandboxed and not accessible by web pages, it poses security risks. A more secure approach would involve prompting for passwords at runtime rather than storing them.
  • Manual Verification: The checkpoint mechanism ensures that manual verification steps can be handled gracefully during playback.

Results

The project is currently in the early stages of development, with most core functionality implemented and a few remaining tasks to complete:

  • Manifest file setup
  • Recording/replaying logic
  • Popup UI creation
  • Daily scheduling implementation
  • Manual testing of recording and playback on real pages
  • Testing daily scheduling

Lessons Learned

  • Selector Strategy: The current approach relies on CSS selectors, which may not always be robust against dynamic DOM changes.
  • Click Navigation Handling: There is a potential issue where fast redirects might cause the last action to be lost if the click handler writes to storage before the browser's default navigation kicks in.
  • Scheduling Limitations: Currently, scheduling is limited to one-time daily triggers per macro and relies on exact URL matching. Improvements could include multiple times/day or day-of-week filters.

Next Steps

  1. Load the extension as an unpacked package in Chrome and manually test recording → playback on a real page.
  2. Test the daily scheduling feature by enabling a schedule for a minute in the future, closing the popup, and confirming that the alarm fires correctly.
  3. Address any outstanding security concerns and improve the checkpoint mechanism.

By following these steps, I aim to complete the development of Action Repeater and ensure it is robust enough for my needs.

Was this useful?