Skip to content

Instantly share code, notes, and snippets.

@lucaswerkmeister
Created September 20, 2025 20:26
Show Gist options
  • Select an option

  • Save lucaswerkmeister/58b3b46b5b6701463cfc58e92f1c32c3 to your computer and use it in GitHub Desktop.

Select an option

Save lucaswerkmeister/58b3b46b5b6701463cfc58e92f1c32c3 to your computer and use it in GitHub Desktop.
user script: Decode Buttondown emails to remove tracking
// ==UserScript==
// @name Decode Buttondown emails to remove tracking
// @namespace http://tampermonkey.net/
// @version 2025-09-20
// @description Replace the URL of links in Buttondown emails with the actual link target, bypassing Buttondown’s redirector (which probably does some tracking stuff)
// @author Lucas Werkmeister
// @match https://buttondown.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=buttondown.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
for (const link of document.querySelectorAll('a[href^="https://buttondown-"]')) {
const originalUrl = link.href;
const match = originalUrl.match(/^https:\/\/buttondown-[0-9][0-9][0-9][0-9].com\/c\/([A-Za-z0-9+/]+)/);
if (!match) {
console.info('Not updating', link, 'because it does not look like a tracking link');
continue;
}
const payload = atob(match[1]); // decode base64
const parts = payload.split('|');
if (parts.length !== 4) {
console.warn('Not updating', link, 'because the payload has the wrong length (expected four pipe-separated parts):', payload);
continue;
}
const [uuid1, uuid2, url, web] = parts;
if (!UUID.test(uuid1) || !UUID.test(uuid2) || web !== 'web') {
console.warn('Not updating', link, 'because the payload looks unexpected:', payload);
continue;
}
link.href = url;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment