This userscript fixes a very "unintended" behavior on x.com where pressing the Back or Forward buttons on a mouse over sponsored posts can open advertiser links in a new tab without an actual, intentional click.
Some sponsored posts on x.com (for example, ads showing From didit.me) attach click and mouseup handlers that do not properly check which mouse button triggered the event.
As a result, pressing the mouse Back button (button 3) while the pointer is over an ad image or video is treated as a valid click, causing x.com to call window.open() and open the advertiser link in a new tab.
Whether this behavior is a genuine oversight or a creative interpretation of what counts as a click, the end result is the same: accidental ad clicks and inflated engagement.
- Intercepts mouse and pointer events in the capture phase
- Blocks events generated by mouse Back and Forward buttons (buttons 3 and 4)
- Prevents those events from reaching x.com ad and media click handlers
- Stops surprise
window.open()calls on sponsored posts
- It does not modify page content
- It does not remove or hide ads
- It does not add tracking or analytics
- It does not break normal browser Back/Forward navigation
The issue is narrowly scoped but highly annoying. A small userscript is the most precise and least invasive way to opt out of this particular definition of an "engaged click" while keeping the rest of the site working normally.
- Install a userscript manager such as Tampermonkey.
- Open the raw
.user.jsfile from this gist. - Tampermonkey will detect the script and prompt you to install it.
- Confirm the installation and reload https://x.com.
The script runs automatically on page load and requires no configuration.
- Chrome / Chromium-based browsers
- Tampermonkey
- Physical mouse with Back/Forward buttons
If you use a mouse with navigation buttons and browse x.com regularly, this script helps ensure that clicks are clicks, and navigation is just navigation.