MediaWiki Version and LocalSettings.php
MediaWiki 1.22.4
$wgAllowUserJs = true;
$wgUseSiteJs = true;
Browser Version
FireFox 28.0
JavaScript Code
$ gvim common.js
function myFunction() {
alert("Hello World!");
}
var onClickAttribute = document.createAttribute("onclick");
onClickAttribute.value="myFunction()";
var button = document.createElement("button");
button.setAttributeNode(onClickAttribute);
button.innerHTML = "Say hello";
if (document.URL === 'http://mywiki.com/w/index.php/User:Pjc/common.js') {
var wikiaArticle = document.getElementById("WikiaArticle");
wikiaArticle.insertBefore(button, wikiaArticle.firstChild);
}
:wq!
Browse to
http://mywiki.com/w/index.php/Special:MyPage/common.js
click "edit this page"
copy/paste common.js into page
click "Save" button
clear the cache in your browser
THE BUTTON DID NOT DISPLAY!
It just displays the code that was entered.