// ==UserScript== // @name betterProfiles // @namespace http://tampermonkey.net/ // @version 2026-07-02 // @description more customizable profiles for darf // @author fungifungus // @match *://darflen.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=darflen.com // @grant none // @require https://cdn.jsdelivr.net/npm/csso@5.0.5/dist/csso.js // ==/UserScript== (function() { 'use strict'; //not done at all, still need to add whitelisting feature+ui... most upcoming features are listed on the darflen discord const api = "https://api.darflen.com"; const descEl = document.querySelector("#content #profile-user-info>.lb-box>p"); const descBox = document.querySelector("#content #profile-user-info>.lb-box"); const settings = document.querySelector("#settings-content"); const tag = "[bP]"; function checkCss(content) { if (!content.endsWith("```")) return; let secondToLast = content.slice(0,-3).lastIndexOf("```"); if (secondToLast === -1) return; let tempcss = content.slice(secondToLast+3,-3) if (tempcss.includes("\n")) return; if (content.slice(secondToLast-(tag.length+2),secondToLast).replace(/\r\n/g, "\n") === "\n"+tag) { if (content[secondToLast-(tag.length+3)]==="\\") return; return tempcss; }; }; if (descEl) { (async () => { const response = await fetch(api + "/users/" + location.pathname.split("/").filter(Boolean).pop()); const data = await response.json(); const desc = data.profile.description; let css; const check = checkCss(desc); if (check !== undefined) { console.log(check); css = check; const style = document.createElement("style"); style.textContent = css; document.querySelector("head").append(style); const last = Array.from(descEl.childNodes).filter(node => node.nodeType === Node.TEXT_NODE && node.textContent.trim()).at(-1); console.log(last); if (last?.textContent === tag) { if (last.previousSibling?.nodeName === "BR") last.previousSibling.remove(); if (last.nextSibling?.matches("code.code-big")) last.nextSibling.remove(); last.remove(); }; const hr = document.createElement("hr"); hr.className = "lb-box-separator"; descBox.append(hr); descBox.append("This user uses BetterProfiles! "); const a = document.createElement("a"); a.textContent = "View their profile CSS (Enable at your own risk...)" descBox.append(a); const code = document.createElement("code"); code.className = "code-big"; code.style.display = "none"; code.textContent = css; descBox.append(code); a.addEventListener("click", function() { const sibling = a.nextElementSibling; if (sibling.style.display === "none") { sibling.style.display = "block"; } else { sibling.style.display = "none"; }; }); }; })(); }; //UI NOW if (false) { //if (settings) { const tools = document.createElement("ul"); tools.style.WebkitBoxPack = "justify"; tools.style.WebkitJustifyContent = "space-between"; tools.style.MozBoxPack = "justify"; tools.style.MsFlexPack = "justify"; tools.style.justifyContent = "space-between"; tools.style.display = "-webkit-box"; tools.style.display = "-webkit-flex"; tools.style.display = "-moz-box"; tools.style.display = "-ms-flexbox"; tools.style.display = "flex"; tools.style.WebkitBoxPack = "justify"; tools.style.WebkitJustifyContent = "space-between"; tools.style.MozBoxPack = "justify"; tools.style.MsFlexPack = "justify"; tools.style.justifyContent = "space-between"; tools.style.WebkitBoxAlign = "center"; tools.style.WebkitAlignItems = "center"; tools.style.MozBoxAlign = "center"; tools.style.MsFlexAlign = "center"; tools.style.alignItems = "center"; tools.style.marginBottom = ".66em"; const count = document.createElement("span"); count.id = "fungifungus-bP-count"; count.className = "lb-composer-length"; count.title = "Characters remaining"; count.style.marginLeft = "auto"; tools.append(count); const label = document.createElement("label"); label.htmlFor = "fungifungus-css"; label.className = "lb-label"; label.textContent = "Profile CSS"; const textarea = document.createElement("textarea"); textarea.name = "fungifungus-css"; textarea.id = "fungifungus-css-textarea"; textarea.className = "lb-textarea"; textarea.cols = 30; textarea.rows = 10; textarea.placeholder = "Your custom CSS"; textarea.style.fontFamily = "var(--font-monospace)"; const submit = document.createElement("button"); submit.type = "fungifungus-profile-css-submit"; submit.className = "lb-button"; submit.id = "fungifungus-profile-css-submit"; submit.textContent = "Submit"; document.querySelector("#customization-form").append(label); document.querySelector("#customization-form").append(tools); document.querySelector("#customization-form").append(textarea); document.querySelector("#customization-form").append(submit); document.querySelector("#submit").style.marginBottom = "1em"; const textareacount = settings.querySelector("#fungifungus-bP-count"); const textareaid = document.querySelector("#fungifungus-css-textarea"); // REMEMEBER TO ADD CSS MINIFIER AND ALSO ACCOUNT THAT FOR THE CHAR COUNT AND ALSO MAKE IT MINIFY WHEN IT SAVES // CSS CAN ONLY EXIST ON ONE LINE // more reminders on dc server let minified; function updatesize() { minified = csso.minify(textareaid.value).css; if (textareacount) { textareacount.innerText = (8192 - settings.querySelector("#description").value.length - minified.length - 7 - tag.length).toString(); } }; updatesize(); settings.addEventListener("keyup", () => { updatesize(); }); settings.addEventListener("keypress", () => { updatesize(); }); }; })();