I’m wanting to remove my user from the about page of some sites I manage. I’m not the one who’s going to delete your account, or anything else. . .
One way is this:
But a plugin seems a bit heavy-handed these days, so I have a theme component that does this:
import { withPluginApi } from "discourse/lib/plugin-api";
const hidden_admins = settings.hidden_admins.split("|");
const PLUGIN_ID = "hide-admins";
export default {
name: "theme-javascript-initializer",
initialize() {
withPluginApi("0.8.30", (api) => {
api.onPageChange((url) => {
if (url != "/about") {
return;
}
for (const admin of hidden_admins) {
var element = document.querySelector(`[data-username=${admin}]`);
if (element === null) {
break;
}
element.classList.add("hide-me");
}
});
});
},
};
Is that stupid for some reason? Does that onPageChange cost very much? The plugin would affect only the about serializer, this does a check on every page change. Is that bad?
There was a topic about just this issue lately that just hard-coded the user in the CSS. Would having just a single CSS in a theme that just did:
That’s mostly what I thought, but I very much appreciate your confirmation. I’ll see about prettying this thing up a bit and making it public and then writing tooling to automate adding it to some sites.