User:Fæ/Geek/fullNameOfShortcut
Appearance
The following code is an iMacro script to expand acronyms typed into the Wikipedia edit box. The acronym must be the last word to be typed in to the edit box in order to be expanded.
/* User:Fae Acronym expander - for all acronyms that have WP:DR style short-cuts on Wikipedia - plus a few of my own local template short-cuts */ //GRAB TEXT AREA iimPlay("CODE:\n\ TAG POS=1 TYPE=TEXTAREA FORM=* ATTR=ID:wpTextbox* EXTRACT=TXT\n\ 'PAUSE"); var ta=iimGetLastExtract(); //GET LAST WORD var lw=ta.replace(/\n/gm," ").replace(/^.*?([^\s]*)$/,"$1"), newsection=(ta.search(/\s/)>-1?false:true); // No spaces then assume new section //alert(lw); //Check exceptions var exArr=new Array( "ADHOM:ad hominem", "RS:reliable source", "V:verifiability", "N:notability", "BRITENG:{{subst!User!Fæ/briteng}}:Spelling", "LINKS:{{subst!User!Chzz/help/links}}:Links", "NAMES:{{subst!User!Fæ/Alumni/Names}}:Lists of names", "PHOTO:{{subst!User!Fæ/help/photo}}:Help for photos", "PHOTOS:{{subst!User!Fæ/help/photo}}:Help for photos", "PRIVACY:{{subst!User!Fæ/help/privacy}}:Guidance on privacy", "REF:Referencing for beginners with citation templates", "REFS:{{subst!User!Fæ/help/refs}}:Guidance on footnotes", "BASICS:How to edit a page (concise)", "THANKS:{{subst!User!Fæ/Thanks\|Thank you \n}}:Thank you", "WEL:{{subst!User!Fæ/Welcome}}:Welcome", "WHYN:{{subst!User!Fæ/help/whyn}}:Guidance on notability", "YOUNG:{{subst!User!Fæ/help/young}}:Guidance on privacy" ), wp='',ec='', rd=''; for(var i=0;i<exArr.length;i++){ if(lw==exArr[i].split(":")[0]||lw==exArr[i].split(":")[0].toLowerCase()){ ec=exArr[i].split(":")[2]; if(ec==null){ec=''}; ec=ec.replace(/ /g,"<sp>"); if(exArr[i].search(/\!/)==-1){ wp="[[WP:"+exArr[i].split(":")[1]+"|]]";break; } else { wp=exArr[i].split(":")[1].replace(/!/g,":");break; } } } if(wp=='' && lw.search(/\{/i)==-1){ //GET WP PAGE TITLE iimPlay("CODE:\n' Get page title *\n\ 'PAUSE\n\ TAB OPEN\n\ TAB T=2\n\ URL GOTO=http://en.wikipedia.org/wiki/Wikipedia:"+lw+"?redirect=no\n\ WAIT SECONDS=1\n\ SET !TIMEOUT_TAG 1\n\ TAG POS=1 TYPE=H1 ATTR=* EXTRACT=TXT\n\ TAG POS=1 TYPE=SPAN ATTR=CLASS:redirectText EXTRACT=HTM\n\ WAIT SECONDS=1\n\ TAB CLOSE"); wp=iimGetLastExtract(1); rd=iimGetLastExtract(2); if(rd.search(/Wiki/)>-1){ rd=rd.replace(/.*?>Wiki/,"Wiki").replace(/<.*/,""); } if(rd.length>6){wp=rd} rd=rd.replace(/.*?#/,""); if(rd.search(/>Help/)>-1){ wp="\[\["+rd.replace(/.*?>Help/,"Help").replace(/<.a>.*/,"")+"\]\]"; }else{ wp="\[\[WP:"+wp.replace(/.*?Wikipedia:(.*)$/,"$1")+(wp.search(/\)$/)>-1?"\]\]":(wp.search(/#/)>-1?"|"+rd+"\]\]":"\|\]\]")); wp=wp.replace(/WP:\[edit\]Help/,"Help"); } //alert(wp); if(wp.search(/Bad title/)>0){wp=''}; } // If last word is subst: link if(lw.search(/\{su/)>0){ var myurl=lw.replace(/^\{\{subst:/i,"").replace(/\}\}$/,"").replace(/\s/g,"_"); // strip iimPlay("CODE:\ 'PAUSE\n\ TAB OPEN\n\ TAB T=2\n\ URL GOTO=http://en.wikipedia.org/w/index.php?title="+myurl+"&action=edit\n\ WAIT SECONDS=1\n\ TAG POS=1 TYPE=H1 ATTR=* EXTRACT=TXT\n\ TAG POS=1 TYPE=TEXTAREA FORM=* ATTR=ID:wpTextbox* EXTRACT=TXT\n\ WAIT SECONDS=1\n\ TAB CLOSE"); wp=iimGetLastExtract(); wp=wp.replace(/\n/g,"oxbrxo") .replace(/<includeonly>|<.includeonly>/g,"") .replace(/<noinclude.*?noinclude>/ig,"") .replace(/^.*?\[EXTRACT\]/,"") .replace(/oxbrxo/g,"\n"); } var patternlw=new RegExp(lw+"$","i"); ta=ta.replace(patternlw, wp); ta=ta.replace(/\n/g,"<br>").replace(/\s/g,"<sp>") .replace(/([^\{])\{\{\{\{([^\{])/g,"$1{{ {{$2") .replace(/([^\{])\{\{\{([^\{])/g,"$1{{subst:((}}\{$2") .replace(/\{\{/g,"#NOVAR#{{"); // alert("ta="+ta); if(newsection==true){ta=ta.replace(/==.*?==<br>/m,"")} iimPlay("CODE:\ TAG POS=1 TYPE=TEXTAREA FORM=* ATTR=ID:wpTextbox* CONTENT="+ta+ (ec!=undefined && ec!='' ? "\nTAG POS=1 TYPE=INPUT:TEXT FORM=* ATTR=ID:wpSummary CONTENT="+ec : ""));