Diferencia entre revisiones de «MediaWiki:Gadget-show-quality-on-cats.js»
Ir a la navegación
Ir a la búsqueda
m (oops) |
m (try this) |
||
Línea 10: | Línea 10: | ||
format: "json", |
format: "json", |
||
prop: "categories", |
prop: "categories", |
||
indexpageids: true, |
|||
cllimit: "max", |
cllimit: "max", |
||
generator: "categorymembers", |
generator: "categorymembers", |
||
Línea 16: | Línea 17: | ||
gcmtype: "page", |
gcmtype: "page", |
||
}).then(function (response) { |
}).then(function (response) { |
||
const all = {} |
|||
⚫ | |||
for (const id of response.query.pageids) { |
|||
const page = response.query.pages[id] |
|||
all[page.title] = page.categories.map(o => o.title) |
|||
} |
|||
⚫ | |||
}) |
}) |
||
Revisión del 06:43 13 ago 2019
mw.hook('wikipage.content').add(function () { // only on categories if (mw.config.get('wgCanonicalNamespace') != 'Category') return console.warn('gadget:', 'show-quality-markers') ;(new mw.Api).get({ action: "query", format: "json", prop: "categories", indexpageids: true, cllimit: "max", generator: "categorymembers", gcmtitle: mw.config.get('wgPageName'), gcmlimit: "max", gcmtype: "page", }).then(function (response) { const all = {} for (const id of response.query.pageids) { const page = response.query.pages[id] all[page.title] = page.categories.map(o => o.title) } console.log(all) }) })