Widget:ProjectLabel: Difference between revisions
From Makerpedia
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
function appStart(){ | function appStart(){ | ||
if(pageParams["page"]){ | if(pageParams["page"]){ | ||
mw.loader.using(['mediawiki.api', 'jquery']).then(()=>{ | |||
new mw.Api().get({ | new mw.Api().get({ | ||
action: 'query', | action: 'query', | ||
| Line 16: | Line 17: | ||
let categories = content.match(regex); | let categories = content.match(regex); | ||
console.log(categories); | console.log(categories); | ||
}); | |||
}); | }); | ||
} | } | ||
Revision as of 02:59, 21 March 2025
<script> function appStart(){ if(pageParams["page"]){ mw.loader.using(['mediawiki.api', 'jquery']).then(()=>{ new mw.Api().get({
action: 'query', prop: 'revisions', rvprop: 'content', titles: pageParams["page"], format: 'json'
}).done(function (pageData) {
var pageId = Object.keys(pageData.query.pages)[0]; var content = pageData.query.pages[pageId].revisions[0]['*']; var pageUrl = mw.util.getUrl(page.title);
const regex = /\[\[Category:(.*?)\]\]/gi; let categories = content.match(regex); console.log(categories);
}); }); } }
if(!window.widgets) window.widgets = []; window.widgets.push(appStart); </script>