Skip to content

Instantly share code, notes, and snippets.

@noaione
Last active December 2, 2023 03:59
Show Gist options
  • Save noaione/edc7ab7a713cabebdd6ca8587d7210da to your computer and use it in GitHub Desktop.
Save noaione/edc7ab7a713cabebdd6ca8587d7210da to your computer and use it in GitHub Desktop.
patreon -> kemono
function unpatreon() {
const KEMONO_DOMAIN = "https://kemono.su";
const url = new URL(window.location);
if (!url.hostname.includes("patreon.com")) {
alert("This scriptlet only works on patreon.com");
return;
}
// get id from URL path
// /posts/xxxx-yyyy-12345
const path = url.pathname.split("/");
const slugs = path[path.length - 1].split("-");
const id = slugs[slugs.length - 1];
if (isNaN(parseInt(id))) {
alert("Unable to get post id from URL");
return;
}
// open new tab with link to kemono.su
const kemonoUrl = `${KEMONO_DOMAIN}/patreon/post/${id}`;
window.open(kemonoUrl, "_blank", "noopener noreferrer");
}
unpatreon();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment