User:Nokib Sarkar/common.js: Difference between revisions
Appearance
Content deleted Content added
Nokib Sarkar (talk | contribs) ←Created page with 'window.onload = function(){ var mems = document.querySelectorAll("div#mw-category-group ul li"); var l = mems.length,url = "https://en.wikipedia.org/w/api.php";...' Tags: Mobile edit Mobile web edit Advanced mobile edit |
Nokib Sarkar (talk | contribs) No edit summary Tags: Mobile edit Mobile web edit Advanced mobile edit |
||
Line 1: | Line 1: | ||
window.onload = function(){ |
window.onload = function(){ |
||
var mems = document.querySelectorAll("div#mw-category-group ul li"); |
var mems = document.querySelectorAll("div#mw-category-group ul li + a"); |
||
var l = mems.length,url = "https://en.wikipedia.org/w/api.php"; |
var l = mems.length,url = "https://en.wikipedia.org/w/api.php"; |
||
l && alert(l); |
l && alert(l); |
Revision as of 11:12, 17 November 2020
window.onload = function(){
var mems = document.querySelectorAll("div#mw-category-group ul li + a");
var l = mems.length,url = "https://en.wikipedia.org/w/api.php";
l && alert(l);
function showMemberData(from = 0, to = 0 ){
var data = {
"action": "query",
"format": "json",
"prop": "langlinks|info",
"titles": [],
"llprop": "url|autonym",
"lllang": "bn"
}
//Prepare the data
for(i = from; i < to; i++)
data.titles.push(mems[i].children[0].title);
// Fetch the data
$.get(url,data,function(res){
var mp = {};
res.query.pages.forEach(
function(a,v){
mp[v.title] = "(" + v.length + " bytes" + (typeof v.langlinks == "undefined"?"": '|<a href ="'+v.langlinks[0].url+"'>"+v.langlinks[0]["*"]+"</a>") + ")";
});
},"json");
//Iterate through result
for(i = from; i < to; i++)
mems[i].innerHTML += mp[mems[i].children[0].title];
//Continue
if(to < l)
setTimeout(function(){
showMemberData(to, to + 49 < l ? to + 49 : l);
},500);
}
}