Skip to content

Instantly share code, notes, and snippets.

@mdashlw
Last active April 8, 2025 04:59
Show Gist options
  • Select an option

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

Select an option

Save mdashlw/a6c66e7681f6502b9118af8e2dcbd85b to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Booru Implications Helper
// @namespace Booru Scripts
// @match https://derpibooru.org/*
// @match https://trixiebooru.org/*
// @match https://furbooru.org/*
// @match https://tantabus.ai/*
// @grant none
// @version 1.0.1
// @author mdashlw
// @description 3/29/2025
// @updateURL https://gist.github.com/mdashlw/a6c66e7681f6502b9118af8e2dcbd85b/raw/booru-implications-helper.user.js
// @downloadURL https://gist.github.com/mdashlw/a6c66e7681f6502b9118af8e2dcbd85b/raw/booru-implications-helper.user.js
// ==/UserScript==
const target = document
.getElementById("tag_implied_tag_list")
?.parentElement?.querySelector(".js-taginput-fancy");
if (!target) {
return;
}
const output = target.insertAdjacentElement(
"afterend",
document.createElement("div"),
);
function refresh() {
const tagNames = [...target.querySelectorAll("[data-tag-name]")].map(
(e) => e.dataset.tagName,
);
if (!tagNames.length) {
output.textContent = "";
return;
}
output.textContent = "Loading...";
fetch(
`/api/v1/json/search/tags?q=${encodeURIComponent(tagNames.join(" || "))}`,
)
.then((resp) => {
if (!resp.ok) {
throw new Error(`API response: ${resp.status} ${resp.statusText}`);
}
return resp;
})
.then((resp) => resp.json())
.then(({ tags }) => {
const missing = Array.from(
new Set(
tags
.flatMap((t) => t.implied_tags)
.filter((t) => !tags.some((tt) => tt.slug === t)),
),
);
if (missing.length) {
output.textContent = `Missing: ${missing.join(", ")}`;
} else {
output.textContent = "All ok";
}
})
.catch((error) => {
console.error(error);
output.textContent = `Error: ${error}`;
});
}
refresh();
new MutationObserver(() => {
refresh();
}).observe(target, { childList: true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment