User:Fæ/Geek/fullNameOfShortcut

''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::Spelling", "LINKS::Links", "NAMES::Lists of names", "PHOTO::Help for photos", "PHOTOS::Help for photos", "PRIVACY::Guidance on privacy", "REF:Referencing for beginners with citation templates", "REFS::Guidance on footnotes", "BASICS:How to edit a page (concise)", "THANKS::Thank you", "WEL::Welcome", "WHYN::Guidance on notability", "YOUNG::Guidance on privacy" ), wp=,ec=, rd=''; for(var i=0;i"); 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>/g,"") .replace(//ig,"") .replace(/^.*?\[EXTRACT\]/,"") .replace(/oxbrxo/g,"\n"); }

var patternlw=new RegExp(lw+"$","i"); ta=ta.replace(patternlw, wp); ta=ta.replace(/\n/g," ").replace(/\s/g,"") .replace(/([^\{])\{\{\{\{([^\{])/g,"$1{{ {{$2") .replace(/([^\{])\{\{\{([^\{])/g,"$1{{subst:((}}\{$2") .replace(/\{\{/g,"#NOVAR#{{"); // alert("ta="+ta); if(newsection==true){ta=ta.replace(/==.*?== /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 : ""));