Difference between revisions of "User:Fbstj/gadget/history-test.js"

Jump to navigation Jump to search
m (try that)
m (try that)
; mw.hook('wikipage.diff').add(function(){
// load the notify function
//mw.loader.load('mediawiki.notification');
const to_secs = 5
// create an api client
//const api = new mw.Api()
// fetch the current RC id for the later request
//const rcid = mw.util.getParamValue('rcid', this.href)
// the old "button"
const old = document.querySelector('.patrollink')
btn.addEventListener('click', function() {
// clicked
mw.notify('clicked')
btn.setAttribute('disabled', true)
btn.replaceWith(spin)
api.postWithToken({
setTimeout(function() { btn.removeAttribute('disabled'); spin.replaceWith(btn) }, 5000);
formatversion: 2,
action: 'patrol',
rcid: rcid,
}).done(function (data) {
if (data.patrol !== undefined) {
const title = new mw.Title(data.patrol.title);
mw.notify(mw.msg('markedaspatrollednotify', title.toText()));
spin.remove()
} else {
mw.notify(mw.msg('markedaspatrollederrornotify'), { type: 'error' });
spin.replaceWith(btn)
}
}).fail(function (data) {
if (error === 'noautopatrol') {
mw.notify(mw.msg('markedaspatrollederror-noautopatrol'), { type: 'warn' });
} else {
mw.notify(mw.msg('markedaspatrollederrornotify'), { type: 'error' });
}
spin.replaceWith(btn)
})
})
// hide old button and show new one