Diferencia entre revisiones de «Usuario:Stargazer/common.js»

m
Not using Demoted like that anymore
m
m (Not using Demoted like that anymore)
// TestCopy makingof the "mark as reviewed" button" gadget that is case insensitive (i.e. make it workworks for {{t|Complete}})
//Test tweak to tag status change gadget for {{t|demoted}} and make first letter case insensitive
mw.hook('wikipage.diff').add(function tag_status_change() {
 
// 2018-11-06 add status-change tags to pages with diffs that change the status
const diff = document.querySelector('.diff')
if (!diff) return;
 
diff.querySelectorAll('.diff-addedline').forEach(function find_status_change(el) {
if (!/\{\{([sS]tub|[pP]artial|[dD]emoted[\S]*|[cC]omplete[\S]*)\}\}/.test(el.innerText)) return
const row = el.parentElement
const rem = row.querySelector('.diff-deletedline')
const add = row.querySelector('.diff-addedline')
const msg = rem.innerText.trim() +' => '+ add.innerText.trim()
 
// guard against tagging latest revision in multi-change diffs
if (diff.querySelector('.diff-multi')) {
// TODO: determine which of the revisions to tag?
console.warn('gadget:', 'tag-status-change', 'ignored on combination diff')
mw.notify('theses revisions contain a potential status-change ('+ msg +') which has been ignored')
return;
}
 
console.warn('gadget:', 'tag-status-change')
 
// send the notification
;(new mw.Api).postWithToken('csrf', {
action: 'tag',
revid: mw.config.get('wgRevisionId'),
add: 'status-change',
reason: msg,
}).then(function notify_success() {
mw.notify('revision tagged with '+ msg)
})
 
 
})
 
})
 
 
 
 
// Test making the "mark as reviewed button" case insensitive (i.e. make it work for {{t|Complete}})
mw.hook('wikipage.content').add(function tag_complete_button() {