User:RainingPain17/wikia.js

//Original script: http://callofduty.wikia.com/wiki/User:Cakemix/Qlicensev2.js ///var QLicensebuttonFirst = false; //Adds the button before the selector ///var QLicenseDebug = false; //Debug to console [You need firebug if firefox, else just press ctrl + shift + J at chrome] ///var QLicenseUseOutGoingLayout = true; //adds the thing outside of the layout [Oasis pl0x] /// Script //$(document)["ready"](function {if(wgCanonicalNamespace=="File");var SelectOption=[];var SelectOptions="";SelectOption[""]="Fair use";SelectOption[""]="Public Domain";SelectOption[""]="GTA SA screenshot";SelectOption[""]="GTA V screenshot";SelectOption[""]="GTA O screenshot";for(i in SelectOption){SelectOptions+=""+SelectOption[i]+" ";} ;var licensedImage="Loading...";var selects=""+SelectOptions+" ";var buttons=" Add license ";if(QLicensebuttonFirst){var buttonAndStuff=buttons+selects;} else {var buttonAndStuff=selects+buttons;} ;if($("#LicensedFile")["length"]!=0||$("#Copyright")["length"]!=0){licensedImage="  This file is licensed.  ";} else {licensedImage="  This file is not licensed.  ";} ;if(QLicenseUseOutGoingLayout){$("footer#WikiaFooter.WikiaFooter")["before"]("  "+buttonAndStuff+licensedImage+"   ");} else {$("#filetoc")["append"](buttonAndStuff+licensedImage);} ;$("#aSubmit")["click"](function {if(QLicenseDebug){console["log"]("Submit clicked on page: "+FileName);console["log"]($("#QLicenseSelect")["val"]+":"+$("#QLicenseSelect :selected")["text"]+" is selected");} ;var ts=Math["round"](( new Date)["getTime"]/1000);callAPI({"action":"query","prop":"info|revisions","intoken":"edit","titles":FileName,"rvprop":"content","rvlimit":"1"},"GET",function (response){console["log"]("It took "+(Math["round"](( new Date)["getTime"]/1000)-ts)+" second(s) to get the data");var pages=response["query"]["pages"];var page=null;for(var i in pages){page=pages[i];} ;var pageText=page["revisions"][0]["*"];console["log"](pageText);pageText+=""+$("#QLicenseSelect")["val"];ts=Math["round"](( new Date)["getTime"]/1000);callAPI({"minor":"yes","summary":"Licensed "+wgTitle+" with Quick license.","action":"edit","title":FileName,"basetimestamp":page["revisions"][0]["timestamp"],"startimestamp":page["starttimestamp"],"token":page["edittoken"],"text":pageText},"POST",function (response){console["log"]("It took "+(Math["round"](( new Date)["getTime"]/1000)-ts)+" second(s) to post the data");if(response["edit"]["result"]=="Success"){document["location"]["replace"](wgScript+"?title="+encodeURIComponent(wgPageName)+"&action=purge");} else {alert("An error occurred while submitting the edit.");} ;} );} );} );} ;} );