How should I make this email icon nonclickable?

How should I disable this Incoming Email model?
And how to disable this
How to disable Incoming Email modal
The discussion revolves around disabling the Incoming Email modal in Discourse. kynic asked how to make the email icon non-clickable and disable the modal. Firepup650 suspected that the icon is only clickable for staff members, which kynic later confirmed.
kynic shared a script using GPT that worked to disable the modal, but Arkshine suggested a more targeted approach using decorateCookedElement. Arkshine provided alternative code that disables the email indicator and hides the HTML.
kynic modified the code to only remove the content and hide it via CSS, and thanked Arkshine for the assistance. Arkshine acknowledged the correct behavior of the icon being only clickable for staff members.
Today I Learned that that icon is clickable.
Haha yea, it is, annoying ![]()
Btw Happy Birthday
![]()
I suspect it’s staff only, just checked on a forum where I don’t have staff, and I cannot click on the icon. (on my phone at least)
Thanks! (though that’s partially timezones, it’s not my birthday here yet
)
I have to see this, thanks for telling me about it. ![]()
Here It shows a cake icon next to your name haha anyway happy birthday in advance I guess I am the first one to say this ![]()
Aa it is only visible to admins so no issues with it.
Anyways, if anyone else like me wants to disable this but can’t find a way here what I did with GPT and it worked great ![]()
<script type="text/discourse-plugin" version="0.8">
api.onPageChange((url, title) => {
// Wait for the page to fully load
Ember.run.scheduleOnce('afterRender', function() {
// Find and remove all details elements with class "elided"
var elidedDetailsList = document.querySelectorAll('details.elided');
elidedDetailsList.forEach(function(elidedDetails) {
elidedDetails.remove();
});
});
});
</script>
Hi kynic,
onPageChange might be a little too broad for usage (and unreliable if you load/update posts).
You can use decorateCookedElement instead. It’s called for every post-cooked element.
Additionally, here is a way to disable the email indicator. It’s just some hack to not include the HTML. If you are curious, you can see the original code here.
<script type="text/discourse-plugin" version="0.8">
api.reopenWidget("post-meta-data", {
html(attrs) {
if (!attrs.via_email) {
return this._super(attrs);
}
// Do not generate "post-email-indicator" widget.
attrs.via_email = false;
const html = this._super(attrs);
attrs.via_email = true;
return html;
}
})
api.decorateCookedElement((element, helper) => {
if (helper?.getModel().via_email) {
element.querySelector('details.elided').remove();
}
}, { onlyStream: true });
</script>
You could also use CSS only to hide them.
.post-info.via-email,
.cooked details.elided {
display: none;
}
Thanks ![]()
I removed the post metadata part as I want this email icon to be shown. ![]()
This is what I am using now to remove the content and hide it via CSS just in case.
<script type="text/discourse-plugin" version="0.8">
api.decorateCookedElement((element, helper) => {
if (helper?.getModel().via_email) {
element.querySelector('details.elided').remove();
}
}, { onlyStream: true });
</script>
.cooked details.elided {
display: none;
}
Thank you for this code
![]()
You’re welcome ![]()
Also, you’re right; only staff can click on the icon! My bad. ![]()
Nice work ![]()