MediaWiki:Gadget-show-quality-on-cats.js
Ir a la navegación
Ir a la búsqueda
Nota: tras guardar, quizás necesites actualizar la caché de tu navegador para ver los cambios.
- Firefox/Safari: Mantén presionada la tecla Mayús mientras pulsas el botón Actualizar, o presiona Ctrl+F5 o Ctrl+R (⌘+R en Mac)
- Google Chrome: presiona Ctrl+Shift+R (⌘+Mayús+R en Mac)
- Internet Explorer: mantén presionada Ctrl mientras pulsas Actualizar, o presiona Ctrl+F5
- Opera: dirígete a Menú → Configuración (Opera → Preferencias en Mac) y luego a Privacidad y seguridad → Borrar datos de navegación → Imágenes y archivos en caché.
mw.hook('wikipage.content').add(function () { const icons = { 'Stubs': [0x25D4], 'Partially complete articles': [0x25D2], 'Articles nearing completion': [0x25D5], 'Complete articles': [0x26AB, 0xFE0E], } // 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", clcategories: Object.keys(icons).map(function(cat) { return 'Category:'+ cat }), generator: "categorymembers", gcmtitle: mw.config.get('wgPageName'), gcmlimit: "max", gcmtype: "page", }).then(function (response) { console.debug(response) const all = {} response.query.pageids.forEach(function (id) { const page = response.query.pages[id] if (!page.categories) return all[page.title] = page.categories[0].title.replace('Category:','') }) document.querySelectorAll('#mw-pages a').forEach(function (el) { const title = el.getAttribute('title') const cat = all[title] if (!cat) return const icon = String.fromCodePoint.apply(null, icons[cat]) el.parentElement.append(icon) }) }) // end of API query }) // end of MW hook