Greasy Fork is available in English.

Diskussionen » Entwicklung

Removing form buttons from a phpbb forum reply editor

§
Veröffentlicht: 12.12.2022

I'd like to remove or disable a couple of buttons from the reply editor of a phpbb forum I'm a member of, because the bbcodes they insert are too tempting but for some reason reserved for "more mortals".

Removing is probably the easiest solution; I have already identified what code to remove to achieve this:

    </button>
        <button type="button" class="button button-secondary bbcode-anchor" name="addbbcode24" value="anchor" onclick="bbstyle(24)" title="Anchor: [anchor]Name of the anchor[/anchor]">
        anchor
    </button>
        <button type="button" class="button button-secondary bbcode-goto" name="addbbcode26" value="goto" onclick="bbstyle(26)" title="Goto: [goto=Anchor Name]Link tekst[/goto]">
        goto
    </button>

In the old days I would do this via a filter in Privoxy but nowadays that requires setting up its https_inspection, which I'd prefer to avoid.

I think it should be possible to do this via an in-browser userscript. I found a promising JS function on here (https://stackoverflow.com/a/50537862/1460868) but have little idea for now how to deploy it (I have no knowledge of Javascript):

  • the function uses node.textContent.replace(); does it take simple expression (if so, how to pass a multi-line pattern?) or a regexp (and if so, what flavour)?
  • some guidelines/pointers as to how to put this function in a user.js/tampermonkey script would be appreciated.
  • or maybe there is already a script that I can use or build upon?

Thanks in advance!

§
Veröffentlicht: 12.05.2023

// ==UserScript==
// @grant GM_addStyle
// ==/UserScript==

GM_addStyle('[name="addbbcode24"],[name="addbbcode26"]{display:none}'}

§
Veröffentlicht: 13.05.2023

Thanks! It even works in `Ferdium` (replacing `GM_addStyle` with the function from https://stackoverflow.com/a/46285637/1460868).

Antwort schreiben

Anmelden um eine Antwort zu senden.