MediaWiki:Gadget-ShowPageStats.js

aus Wiki Aventurica, dem DSA-Fanprojekt
Leere nach dem Speichern den Browser-Cache, um die Änderungen sehen zu können.
  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Internet Explorer: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
  • Opera: Extras → Internetspuren löschen … → Individuelle Auswahl → Den kompletten Cache löschen

Mehr Hilfe zu Cascading Style Sheets und JavaScript gibt es auf Hilfe:CSS und Hilfe:Javascript.

/*
 * Simple script to scrape a page's html comments (looking for 'served by', 'newpp' and 'Transclusion expansion time report').
 * imported 20.05.2024 from https://en.wikipedia.org/wiki/User:Splarka/showcomments.js
 * author: [[wpen:User:Splarka]] on https://en.wikipedia.org
 * adapted for Wiki Aventurica by StipenTreublatt
*/

$(function() {
  mw.util.addPortletLink('p-tb','#','Seitenerstellungs-Statistik','t-sps');
  $("#t-sps").on("click", function(){
      alert(dumpComments(document.getElementsByTagName("body")[0]));
  });
})

function dumpComments(obj) {
  var childs = 0; var txt = '';
  if(obj.nodeType == 8 && obj.nodeValue.search(/(NewPP|Served by|Transclusion expansion time report)/) != -1) { 
    txt += obj.nodeValue;
  }
  while(obj.childNodes[childs]) {
    txt += dumpComments(obj.childNodes[childs]);
    childs++;
  }
  return txt;
}