User:Fbstj/docs/tag-changes

From The Coppermind
Jump to navigation Jump to search

to tag a change send:

(new mw.Api).postWithToken('csrf', { action: 'tag', revid: mw.config.get('wgRevisionId'), add: 'status-change'})


The API doesn't allow you to find the categories of a specific revision (it converts revid into the page and then merges duplicates and returns info about the latest page). The API has a query for templates and a query for categories, but the above version doesn't help.

The mw.config.get('wgCategories') array contains the categories of the revision being viewed, but there's no way to get this out of other pages.

const diff = document.querySelector('.diff')
diff.querySelectorAll('.diff-addedline').forEach(el => {
  if (!/\{\{(stub|partial|complete)\}\}/.test(el.innerText)) return
  const row = el.parentElement
  const msg = row.children[1].innerText.trim(), '=>', row.children[3].innerText.trim()
  (new mw.Api).postWithToken('csrf', { action: 'tag', revid: mw.config.get('wgRevisionId'), add: 'status-change', message: msg, })
})

The above code-snippet will find lines that have changed to being one of the article status templates and print out what they changed from.