Jump to content

User:Chris G/fake toolserver apps.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
function getParameter(p) {
  var re = new RegExp('&'+p+'=([^&]*)','i');
  var c = window.location.search; 
  return unescape((c=c.replace(/^\?/,'&').match(re)) ?c=c[1] :c="");
}
 
function fakeSpecialPages() {
  if (wgPageName == "Special:EditCount") {
    document.getElementsByTagName("h1")[0].innerHTML = document.title = "Edit Count: Chris G";
    document.getElementsByTagName("p")[1].innerHTML = "";
    document.getElementsByTagName("p")[0].innerHTML = "<iframe id=\"iframe\" src=\"https://toolserver.org/~chris/test.html\" frameborder=0  style=\"width: 100%;\"></iframe></div>";
  } else if (wgPageName == "Special:AppealBlock") {
    document.getElementsByTagName("h1")[0].innerHTML = document.title = "Appeal Your Block";
    document.getElementsByTagName("p")[1].innerHTML = "";
    document.getElementsByTagName("p")[0].innerHTML = "<iframe id=\"iframe\" src=\"https://toolserver.org/~chris/unblock.html\" frameborder=0  style=\"width: 100%;\"></iframe></div>";
  } else if (wgPageName == "Special:RequestAccount") {
    document.getElementsByTagName("h1")[0].innerHTML = document.title = "Request Account";
    document.getElementsByTagName("p")[1].innerHTML = "";
    document.getElementsByTagName("p")[0].innerHTML = "<iframe id=\"iframe\" src=\"https://toolserver.org/~chris/acc.html\" frameborder=0  style=\"width: 100%;\"></iframe></div>";
  } else if (wgPageName == "Special:GAStats") {
    document.getElementsByTagName("h1")[0].innerHTML = document.title = "Good Article Reviews by User";
    document.getElementsByTagName("p")[1].innerHTML = "";
    document.getElementsByTagName("p")[0].innerHTML = "<iframe id=\"iframe\" src=\"https://toolserver.org/~chris/gastats.php?noshow\" frameborder=0  style=\"width: 100%;\"></iframe></div>";
  }
  setIframeHeight(document.getElementById('iframe'));
}

function setIframeHeight(iframe) {
	var other_domain = 'https://toolserver.org';
    window.addEventListener('message', function(event) {
      if (event.origin !== other_domain) return; // only accept messages from the specified domain
      if (isNaN(event.data)) return; // only accept something which can be parsed as a number
      var height = parseInt(event.data); //+ 32; // add some extra height to avoid scrollbar
      iframe.height = height + "px";
    }, false);
}

 
addOnloadHook(fakeSpecialPages);