Skip to content

Instantly share code, notes, and snippets.

@mdashlw
Last active May 24, 2025 12:19
Show Gist options
  • Select an option

  • Save mdashlw/fe76f38223f862881c4ea1aab728cd65 to your computer and use it in GitHub Desktop.

Select an option

Save mdashlw/fe76f38223f862881c4ea1aab728cd65 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Booru Search Resolve IDs
// @version 1.0
// @author mdashlw
// @namespace Booru Scripts
// @match https://*.derpibooru.org/*
// @match https://*.trixiebooru.org/*
// @match https://*.tantabus.ai/*
// @match https://*.furbooru.org/*
// @description 5/24/2025
// ==/UserScript==
const blockTitle = document.querySelector(
"#imagelist-container .block__header__title",
);
if (!blockTitle) {
return;
}
// I hate the web
function refresh(el) {
const children = [...el.childNodes].map((c) => c.cloneNode(true));
el.innerHTML = "";
el.append(...children);
}
const seenTerms = new Set();
for (const match of blockTitle.textContent.matchAll(
/(?:uploader_id|true_uploader_id|faved_by_id|upvoted_by_id|downvoted_by_id|hidden_by_id|deleted_by_user_id):\s*(\d+)/g,
)) {
const [term, userId] = match;
if (seenTerms.has(term)) {
continue;
}
seenTerms.add(term);
fetch(`/api/v1/json/profiles/${userId}`)
.then((resp) => {
if (!resp.ok) {
throw new Error(`Response error: ${resp.status} ${resp.statusText}`);
}
return resp.json();
})
.then(
({ user }) => {
const a = document.createElement("a");
a.textContent = user.name;
a.href = `/profiles/${user.slug}`;
a.style.paddingLeft = "revert";
a.style.paddingRight = "revert";
return a.outerHTML;
},
(error) => {
return error;
},
)
.then((value) => {
blockTitle.innerHTML = blockTitle.innerHTML.replaceAll(
new RegExp(`${term}\\b`, "g"),
`${term} (${value})`,
);
refresh(blockTitle);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment