Difference between revisions of "MediaWiki:Gadget-tag-complete-button.js"

m
remove from cat
m (tweak)
m (remove from cat)
 
(3 intermediate revisions by the same user not shown)
mw.hook('wikipage.content').add(function tag_complete_button() {
 
// only show button on latest revision of page
// find the {{complete}} template
if (mw.config.get('wgCurRevisionId') != mw.config.get('wgRevisionId')) return;
 
// find the {{t|complete}} template
const notice = document.querySelector('.quality-complete')
if (!notice) return;
 
// try to edit the article
return api.edit(page_name, function try_signing_article(revision) {
 
return {
// find {{t|complete}} and replace with {{t|complete|~x4}}
text: revision.content.replace( '{'+'{complete}}', '{'+'{complete|~~'+'~~}}' ),
summary: 'mark as complete',
}
 
}).catch(console.warn).then(function try_tagging_revision(revision) {
console.debug('gadget:', 'tag-complete-button', 'revision:', revision)
if (revision.nochange === true) return
add: 'completed',
reason: 'from tag-complete-button gadget',
}).catch(console.warn).then(function show_result_of_complet_button_press() {
// show the user that it worked
mw.notify('Article marked as complete?')
40,275

edits