DEV Community

Fernando Paladini
Fernando Paladini

Posted on

Build a Safety-Aware Manifest V3 Extension for X with Plain JavaScript

Automating a browser action is easy to demonstrate and surprisingly difficult to constrain. A script that clicks a button can also click the wrong button, run while you are looking at another tab, or quietly collect more access than it needs.

This tutorial walks through the design of X Like Automator, a public MIT-licensed browser extension that likes visible posts in an already-open X tab. The project uses Manifest V3, plain JavaScript, no build step, no runtime dependencies, and a test suite built on Node's built-in test runner.

The goal is not to encourage high-volume activity. The useful engineering lesson is how to make a browser automation boundary explicit: a pure policy engine decides what is allowed, while a DOM adapter performs only the approved action.

TL;DR

  • Clone the tagged v1.1.0 release.
  • Run npm test to execute 171 tests.
  • Load the repository folder as an unpacked extension in Chrome, Edge, or Brave.
  • Open X in a tab where you are already signed in, then start a conservative session.
  • Keep the interval and optional cap modest, and stop if X shows an automation warning.

Prerequisites

You need a Chromium browser with Manifest V3 support, such as Chrome, Edge, or Brave. The extension relies on the CSS :has() selector, so the project documents Chrome or Edge 105 and newer, or a current Brave release.

You also need an X account that is already signed in in a normal browser tab. The extension does not implement login, read passwords, read cookies, or use an X API token. Node.js 20 or newer is needed only if you want to run the tests.

The exact stable release used here is v1.1.0. It is also the version declared in manifest.json and package.json.

Get the source and run the test gate

The project has no dependency installation step. Clone the release tag and run its single test command:

git clone --branch v1.1.0 https://github.com/paladini/x-like-automator.git
cd x-like-automator
npm test
Enter fullscreen mode Exit fullscreen mode

The tagged checkout reports 171 passing tests. They cover the policy engine, content-script behavior, popup controls, Manifest V3 permissions, language parsing, reload and resume behavior, and documentation consistency.

The test result is more useful than a generic claim that the extension is safe. It demonstrates specific invariants. For example, the suite verifies that cookies, login, direct messages, replies, follows, quote posts, and cookie collection are refused. It also verifies that the extension's only allowed content action is a like, with plain repost handled as an explicitly tested optional path in the current release.

Load the extension without a build step

The repository itself is the extension. The top-level folder must contain manifest.json.

  1. Open chrome://extensions, edge://extensions, or brave://extensions.
  2. Enable Developer mode.
  3. Choose Load unpacked.
  4. Select the cloned x-like-automator folder.
  5. Pin the extension if you want the popup to be easy to reach.

The release's manifest declares only the storage permission and host access for https://x.com/* and https://twitter.com/*:

{
  "manifest_version": 3,
  "permissions": ["storage"],
  "host_permissions": ["https://x.com/*", "https://twitter.com/*"]
}
Enter fullscreen mode Exit fullscreen mode

This narrow permission set is an important part of the design. A browser extension cannot make its permissions harmless through documentation alone. The manifest is the enforceable boundary that users can inspect before loading the folder.

Understand the policy boundary

The project separates decisions from browser interaction:

popup/       controls and settings
content/     DOM reader and click adapter
lib/policy   pure decision engine
manifest     permissions and host boundary
test/        policy, DOM seam, UI, and manifest checks
Enter fullscreen mode Exit fullscreen mode

lib/policy.js validates settings, classifies the current X URL, chooses the next eligible post, calculates a delay, and returns a plan. The content script reads visible posts and applies that plan to the page. The popup saves settings and sends start or stop messages.

That split gives you a useful review question: is a behavior a policy decision or a DOM operation? A policy test can run without a browser. A DOM test can focus on selectors and button states without recreating the whole decision algorithm.

The session loop also has explicit refusal states. A login wall does not trigger a click. An unsupported page such as messages or settings does not trigger a click. A hidden document or unfocused window pauses the session. When the tab becomes active again, the same session can resume with its count and seen-post state.

Start a conservative first session

Open https://x.com/home in a tab where you are already signed in. Click the extension icon and review the popup settings before pressing Start.

The stable release defaults to a five-second interval, no hard session cap, the option to include the original post in a reply thread, and the Brazilian Portuguese interface. The interval setting accepts whole seconds from 1 through 60. An optional cap accepts values from 1 through 1,000,000.

For a first check, use a larger interval and turn on a small cap. This makes it easier to inspect behavior and stop early. The extension randomizes the delay inside the selected interval, pauses when the tab or window is inactive, and waits when no eligible post is visible. It does not try to bypass an X automation warning. The documented behavior is to wait and then resume.

Press Start and observe the counter. The extension processes visible eligible posts, skips posts already liked or already seen in the current session, and scrolls when it needs more content. Press Stop to end the session.

The extension also reloads the tab on a five-minute cycle and stores enough session state to resume after that reload. A browser restart is different: the documentation says the volatile run state is cleared, so you need to press Start again.

Verify the important boundaries

You can verify the design without relying on a live account:

npm test
Enter fullscreen mode Exit fullscreen mode

Then inspect these files in the tagged checkout:

The test suite checks that the content code does not touch cookies or an X API token, that unsupported surfaces are refused, and that the manifest has storage-only permissions. Those checks are reproducible evidence for the repository's stated boundaries.

Failure modes and honest limitations

This is page automation, not an official X integration. It depends on the DOM labels and structure that X exposes to the browser. A site change can make a selector stop matching or cause a feature to behave differently. The repository's tests reduce regression risk, but they cannot guarantee compatibility with every future X UI change.

Automated likes can conflict with X rules and Terms of Service. An account may be rate-limited, restricted, or suspended. The project's own warning says that account responsibility remains with the user. Use a conservative interval, enable a cap when evaluating the extension, and stop immediately if the site displays a warning.

The extension also does not provide a universal bot-detection solution. Its pause-on-inactivity behavior and warning response are guardrails, not a promise that activity will be considered human or permitted. Treat the tool as a local experiment whose effects are visible in your own account.

FAQ

Does it need an API key?

No. The extension operates in the X tab that is already open. It does not request an X API token or send its own network requests.

Does it work on every X page?

No. The documented supported surfaces are the home timeline, search results, profiles, and single-post or reply-thread pages. Explore, notifications, messages, settings, compose, and non-X pages are refused.

Why separate policy from the content script?

It makes the safety rules testable without a browser and keeps DOM changes from silently changing the decision logic. The policy returns an explicit plan, and the adapter applies only that plan.

Is there a build command?

No. The extension is plain JavaScript and can be loaded unpacked directly from the repository. Node 20 or newer is used for the test suite.

Takeaway

The most reusable part of X Like Automator is not its button click. It is the contract around the click: narrow permissions, explicit refusal states, a pure policy layer, a small DOM adapter, and tests that verify both behavior and documentation.

If you build browser automation, start by writing down the actions your tool must refuse. Then make those refusals executable in tests and visible in the manifest. That approach will not eliminate site changes or platform policy risk, but it gives you a boundary you can inspect, review, and maintain.

This tutorial was prepared with AI assistance for research organization and drafting. The repository, tagged source, documentation, manifest, and test results were checked against the claims before publication.

What other browser-automation boundary would you want to see expressed as a tested policy instead of an implicit convention?

Top comments (0)