User:JJPMaster/Scripts/GreenAndGold.js: Difference between revisions

Content deleted Content added
No edit summary
m JJPMaster moved page User:JJPMaster/GreenAndGold.js to User:JJPMaster/Scripts/GreenAndGold.js: cleaning up my userspace
 
(17 intermediate revisions by the same user not shown)
Line 1:
$(function() {
const wikiSlash = mw.config.get("wgArticlePath").replace("$1", '');
const links = $("#mw-content-text").find(`a[href*^='${wikiSlash}']`);
let titles = [];
let finalTitle;
$(links).each(function() {
titles.push(decodeURI($(this).attr("href").replace(wikiSlash, '')));
finalTitle = titles.join("|");
});
let queryableTitles = titles.slice(0, 40);
$.get('/w/api.php?' +
finalTitle = titlesqueryableTitles.join("|");
$.param({
var params = {
format: 'json',
action: 'query',
prop format: 'categoriesjson',
list: 'categorymembers',
titles: finalTitle,
cmtitle: "Featured articles"
origin: ___location.protocol + '//' + ___location.host
},
})).done(function() { console.log(data) });
api = new mw.Api();
 
api.get( params ).done( function ( data ) {
// var pages = data.query.pages,
// p;
// for ( p in pages ) {
// pages[ p ].categories.forEach( function ( cat ) {
// console.log( cat.title );
// } );
// }
console.log(data);
});
// $.get('/w/api.php?' +
// $.param({
// format: 'json',
// action: 'query',
// prop: 'categories',
// titles: finalTitle,
// })).done(function(data) { console.log(data) });
});