Benutzer:Totto/common.js: Unterschied zwischen den Versionen

K
onlinecounter
KKeine Bearbeitungszusammenfassung
K (onlinecounter)
Zeile 1:
 
 
function mainTotto(){
 
Zeile 18 ⟶ 20:
container3.setAttribute("id","TottoScrollDown");
containerQuickJump.prepend(container3);
var container4 = document.createElement("li");
container4.setAttribute("class","TottoCustomContainer");
container4.innerHTML='<a onclick="onlinecounter()" dir="auto" title="Online Counter">0</a>';
container4.setAttribute("id","TottoOnlineCounter");
containerQuickJump.prepend(container4);
//addHotkey("s","scrollToBottom");
//addHotkey("u","scrollToTop");
//addHotkey("p","preview");
//AddAcessKeys();
onlinecounter()
}
Zeile 103 ⟶ 110:
}
function refresh(){
onlinecounter()
}
 
function onlinecounter(){
var url="https://conanwiki.org/wiki/Spezial:Wer_ist_gerade_online"
fetch(url).then(function (response) {
// The API call was successful!
return response.text();
}).then(function (html) {
var num=0;
// Convert the HTML string into a document object
var parser = new DOMParser();
var doc = parser.parseFromString(html, 'text/html');
var cont=document.getElementById("TottoOnlineCounter").getElementsByTagName("a")[0];
var c=doc.getElementById("mw-content-text")
num=c.getElementsByTagName("ul")[0].getElementsByTagName("li").length
cont.innerHTML=num;
console.log(num)
}).catch(function (err) {
// There was an error
console.warn('Something went wrong.', err);
document.getElementById("TottoOnlineCounter").getElementsByTagName("a")[0].innerHTML=0;
});
 
 
 
 
}
 
 
 
1.060

Bearbeitungen