Advice on a hide admin from about page theme component--is this going to slow things down?

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:

.about-page div[data-username="pfaffman"] {
  display: none !important;
}

be better? It wouldn’t be useful for anyone other than me, which is why I sort of like this theme component idea.

2 Likes

So for every page turn except “about” you are processing ~two lines of extra javascript?

No I don’t think that is bad given the enormous amount of javascript that runs all the time on Discourse :slight_smile:

2 Likes

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.

Thanks very much.

2 Likes

So Jay would this be a plugin to install or a Theme-component?

I think this could be handy to even extend functionality to even Mods. For some use cases.

This is a theme component. I’m still cleaning it up a bit. I’ll make a proper theme page for it on the next while, but you can see GitHub - literatecomputing/discourse-hide-admins-about: Theme component to hide some admin users from about page if you’re excited to try it out.

2 Likes

That is quite cool. I am content though to wait for your official roll out.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.