Last active
August 13, 2025 02:01
-
-
Save pioug/08171fdb17554130ca1da6aa5ee307d8 to your computer and use it in GitHub Desktop.
Link Hive Dashboard to Curator
This file contains hidden or 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
| // ==UserScript== | |
| // @name Hive x Curator | |
| // @namespace http://tampermonskey.net/ | |
| // @version v2 | |
| // @description Link reported content to BandLab Curator | |
| // @author Gilles | |
| // @match https://dashboard.thehive.ai/app/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function () { | |
| "use strict"; | |
| const curator = "https://curator.bandlab.com"; | |
| const observer = new MutationObserver(wrapAll); | |
| observer.observe(document.body, { childList: true, subtree: true }); | |
| function wrapAll() { | |
| observer.disconnect(); | |
| const elements = document.querySelectorAll("*"); | |
| elements.forEach((el) => { | |
| if ( | |
| el.childNodes.length === 1 && | |
| el.childNodes[0].nodeType === Node.TEXT_NODE | |
| ) { | |
| if (el.textContent.includes("User ID:")) { | |
| const next = el.nextElementSibling; | |
| console.log("Add link to", next); | |
| const anchor = document.createElement("a"); | |
| anchor.href = `${curator}/users/${next.textContent}`; | |
| anchor.target = "_blank"; | |
| anchor.textContent = next.textContent; | |
| next.textContent = ""; | |
| next.appendChild(anchor); | |
| } else if (el.textContent.includes("Post ID:")) { | |
| const texts = Array.from(document.querySelectorAll("*")).map(el => el.textContent); | |
| const type = (function () { | |
| if (texts.includes('"ChatMessage"')) { | |
| return "users"; | |
| } | |
| if (texts.includes('"Song"')) { | |
| return "projects"; | |
| } | |
| if (texts.includes('"UserProfile"')) { | |
| return "users"; | |
| } | |
| if (texts.includes('"BandProfile"')) { | |
| return "bands"; | |
| } | |
| if (texts.includes('"CommunityProfile"')) { | |
| return "communities"; | |
| } | |
| return "posts"; | |
| })(); | |
| const next = el.nextElementSibling; | |
| console.log("Add link to", next); | |
| const anchor = document.createElement("a"); | |
| anchor.href = `${curator}/${type}/${toUUID(next.textContent)}`; | |
| anchor.target = "_blank"; | |
| anchor.textContent = next.textContent; | |
| next.textContent = ""; | |
| next.appendChild(anchor); | |
| } | |
| } | |
| }); | |
| observer.observe(document.body, { childList: true, subtree: true }); | |
| } | |
| function toUUID(str) { | |
| const hex = str.replace(/[^a-fA-F0-9]/g, "").slice(0, 32); | |
| return [ | |
| hex.slice(0, 8), | |
| hex.slice(8, 12), | |
| hex.slice(12, 16), | |
| hex.slice(16, 20), | |
| hex.slice(20), | |
| ].join("-"); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment