Last active
December 2, 2023 03:59
-
-
Save noaione/edc7ab7a713cabebdd6ca8587d7210da to your computer and use it in GitHub Desktop.
patreon -> kemono
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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