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

Content deleted Content added
last resort
m JJPMaster moved page User:JJPMaster/GreenAndGold.js to User:JJPMaster/Scripts/GreenAndGold.js: cleaning up my userspace
 
(20 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() {
$.ajax({
titles.push(decodeURI($(this).attr("href").replace(wikiSlash, '')));
dataType: 'jsonp',
url: `/w/api.php?action=query&prop=categories&titles=${finalTitle}`,
success: function(data) { console.log(data); }
});
let queryableTitles = titles.slice(0, 40);
finalTitle = titlesqueryableTitles.join("|");
var params = {
action: 'query',
format: 'json',
list: 'categorymembers',
cmtitle: "Featured articles"
},
api = new mw.Api();
 
$api.get(links params ).eachdone( function ( data ) {
// var pages = data.query.pages,
titles.push($(this).attr("href").replace(wikiSlash, ''));
// p;
finalTitle = titles.join("|");
// 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
success: // })).done(function(data) { console.log(data); });
});