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

m
Fbstj moved page User:Fbstj/common.js to User:Fbstj/gadget/history-test.js without leaving a redirect
m (oops)
m (Fbstj moved page User:Fbstj/common.js to User:Fbstj/gadget/history-test.js without leaving a redirect)
 
(155 intermediate revisions by the same user not shown)
mw.hook('wikipage.content').add(function revs_gadget() {
/* Add edit buttons to templates */
 
$('.navbar').attr('id', function(i, v) { $('.title', this).append("<span style='float: right; font-size: small;' >[<a href='/edit/Template:"+v+"'>edit</a>]</span>"); })
const pageid = mw.config.get('wgArticleId')
const query = {
// request the history of this page
pageids: [pageid],
prop: 'revisions',
// request the oldest edits first
rvdir: 'newer',
// request as many as you can at once
rvlimit: 'max',
// properties to fetch:
rvprop: [ 'ids', 'user', 'timestamp', 'size', 'tags', ],
}
const api = new mw.Api({ parameters: query, })
 
api.get().then(function old_hist(resp) {
 
const page = resp.query.pages[pageid]
page.revisions.forEach(console.log)
 
})
 
$('.infobox').attr('id', function(i, v) {
if (!v) return v;
v = v.replace('.26', '&').replace('.27', "'");
var a = "<a href='/edit/Template:" + v +"'>edit</a>";
$('.title', this).append("<span style='float: right; font-size: small;' >[" + a + "]</span>");
})