User:Fetchcomms/hangon.js

$(function {    var changeCSDToHangon = document.getElementById('hangonbutton');    if (changeCSDToHangon) {        try {            mw.loader.load('https://secure.wikimedia.org/wikinews/en/w/index.php?title=user:Bawolff/mwapilib2.js&action=raw&ctype=text/javascript');            var button = document.createElement('button');            button.type = 'button';            button.appendChild(changeCSDToHangon .firstChild.firstChild);            changeCSDToHangon .replaceChild(button, changeCSDToHangon .firstChild);            button.onclick = function  {                if (this && this.firstChild && this.firstChild.data) this.firstChild.data = "Loading ...";                api(wgPageName).getPage.                    setDefaultSummary("Please do not delete this page yet").                    replace(/^/, "\{\{hangon}}\n").                    savePage.                    lift(function  { alert("A \"hang on\" notice has been added to the page. This will alert administrators that you disagree with this speedy deletion request, but you MUST also explain why you believe this page should not be deleted on the next page."); if (wgNamespaceNumber == 2) var talkPage = 'User talk:' + wgTitle; else var talkPage = 'Talk:' + wgPageName; window.location.href="http://en.wikipedia.org/w/index.php?action=edit&preload=Template%3AHangon+preload&editintro=User%3AFetchcomms/test/foo&preloadtitle=Contested+deletion&section=new&title=" + talkPage + "&create=Click+here+to+contest+this+speedy+deletion"; }).                   exec;            }        }        catch (e) {}    } });