Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
//<pre><nowiki>// __________________________________________________________________________// BEGIN Instant append link stuffaddOnloadHook(check_instant_append_link);// This is the function to call, the others are just internal handlers// page : Page name// append : Text to append// linktitle : Text between <a> and </a>// pre : 0 to append text, 1 to put it at the top of the pagefunctionget_instant_append_link(page,append,linktitle,pre){append=encodeURIComponent(append);append=encodeURIComponent(append);varid=encodeURIComponent(encodeURIComponent(page)+"_"+append+"_"+linktitle);id=id.split("'").join("_");pre=pre==1?"1":"0";// Ugly but quick to hack...varret="<a href='javascript:run_instant_append_link(\"";ret+=id+"\",\"";ret+=encodeURIComponent(page)+"\",\"";ret+=encodeURIComponent(append)+"\",\"";ret+=pre+"\""+");'>";ret+=linktitle+"</a>";varspan=document.createElement("span");span.id=id;span.style.padding="5px";span.innerHTML=ret;returnspan;}functioncheck_instant_append_link(){if(wgAction!="edit")return;// Not an edit page, so no business...varial=instant_append_link_get_param("ial");if(!ial)return;ial=decodeURIComponent(ial);varial_pre=instant_append_link_get_param("ial_pre");if(ial_pre==1)document.editform.wpTextbox1.value=ial+document.editform.wpTextbox1.value;elsedocument.editform.wpTextbox1.value+=ial;ial=ial.split("\n").join(" ");document.editform.wpSummary.value="Adding \""+ial+"\" (using [[MediaWiki:GalleryDetails.js|GalleryDetails.js]])";document.editform.wpSave.click();setTimeout("window.close();",5000);}functioninstant_append_link_get_param(paramName,h){if(typeofh=='undefined')h=document.location.href;varcmdRe=RegExp('[&?]'+paramName+'=([^&]*)');varm=cmdRe.exec(h);if(m){try{returndecodeURI(m[1]);}catch(someError){}}returnnull;}functionrun_instant_append_link(id,page,append,pre){id=encodeURIComponent(id);append=decodeURIComponent(append);varspan=document.getElementById(id);while(span.firstChild)span.removeChild(span.firstChild);varurl=mw.config.get('wgServer')+mw.config.get('wgScript')+"?title="+page;url+="&action=edit";url+="&ial="+append;if(pre==1)url+="&ial_pre=1";variframe=document.createElement("iframe");iframe.src=url;iframe.style.width="100px";iframe.style.height="40px";span.appendChild(iframe);}// __________________________________________________________________________// END Instant append link stuff//</nowiki></pre>