wikimedia / mediawiki-gadgets-RTRC

Mirror of https://gerrit.wikimedia.org/g/mediawiki/gadgets/RTRC.
https://meta.wikimedia.org/wiki/RTRC
MIT License
26 stars 11 forks source link

Extension hooks #94

Closed sportshead closed 3 years ago

sportshead commented 3 years ago

I love the RTRC gadget and use it way more than other patrol tools. I was wondering if there would be any way for RTRC to call hooks whenever certain events happen, such as onNewDiff or something. And then inside the hook there could be a way to open the next diff (while using autoDiff). E.g. an extension could push a hook like this:

window.RTRCHooks.onNewDiff.push((ctx)=>{
    const someCustomElement = document.createElement("button")
    button.onClick = () => {
        doCustomStuff();
        ctx.nextDiff();
    };
    ctx.diffFrame.appendChild(someCustomElement);
});

The reason I'm asking is that I'd like to combine RTRC and RedWarn in order to replace the (very bad) RedWarn patrol feature. Having hooks and being able to inject RedWarn elements would be a lot faster than having to click "open in wiki" and using the RedWarn elements.

sportshead commented 3 years ago

Nevermind, I've found mw.hook('wikipage.diff').add

Krinkle commented 3 years ago

@sportshead Sorry about the delay. Yep, that's the one!

More info on doc.wikimedia.org