User:Ais523/autotag.js

// //From WP:US/S/Get Tidy Title, a prereq for my AutoTag script function get_tidy_title { var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href; // cut everything up to "title=" from the start and everything past "&action=edit" from the end editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));

return editlk; }

function showatmenu { if(document.getElementById("atmenu").style.display=="none") document.getElementById("atmenu").style.display="block"; else document.getElementById("atmenu").style.display="none"; }

// AutoTag's tagging function. function atspeedy(dbplate) { var atmenuhtm=" "; document.getElementById("atform").innerHTML=atmenuhtm; document.getElementById("atform").scrollIntoView(true); }

// AutoTag's warning function. warnplate is the template to use (possibly check for // -n somehow?), blockreq, if true, signifies that instead of a warning a request to // block should be posted on AIV, AN/I, AN3, or PAIN, or a protection request at RPP. function atwarn(warnplate,blockreq,edsum,warnlevel) { if(blockreq) { //Just link to the appropriate page for the time being; this can be enhanced //(especially wrt AIV) later location.href="http://en.wikipedia.org/wiki/WP:"+warnplate; return; } var atmenuhtm=" "; document.getElementById("atform").innerHTML=atmenuhtm; document.getElementById("atform").scrollIntoView(true); }

//From User:Lupin/autoedit.js. Renamed because I know many users use popups, //and I don't want to cause a naming conflict. Edited to decode + to space as well, //and to use a decoding function that handles more characters. function atGetParamValue(paramName) { var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)'); var h=document.location; var m; if (m=cmdRe.exec(h)) { try { while(m[1].indexOf('+')!=-1) {       m[1]=m[1].substr(0,m[1].indexOf('+'))+" "+m[1].substr(m[1].indexOf('+')+1); }     return decodeURIComponent(m[1]); } catch (someError) {} } return null; };

//AutoTag's automatic editing function: for user warnings and tags $(function { if(location.href.indexOf("withautotag=warn")!=-1)  {    document.editform.wpSummary.value=atGetParamValue('autotagsum')+      ;    document.editform.wpTextbox1.value='{'+'{subst:'+atGetParamValue('autotagwp');    var atf=atGetParamValue('autotagflag');    //Only 0, 1, 2, 4 supported for the time being    if(atf=='4'&&atGetParamValue('autotag-n')==) atf='0';    if(atf=='2'&&atGetParamValue('autotag-n')=='')    {      alert("You didn't enter a page, although this is required.");      return; //Leave the user in edit mode    }    if(atf=='0') document.editform.wpTextbox1.value+='}} '+atGetParamValue('autotagsig');    if(atf=='1') document.editform.wpTextbox1.value+='|sig='+      atGetParamValue('autotagsig')+'}}';    if(atf=='2') document.editform.wpTextbox1.value+='|'+atGetParamValue('autotag-n')+      '}} '+atGetParamValue('autotagsig');    if(atf=='4') document.editform.wpTextbox1.value+='-n|'+atGetParamValue('autotag-n')+ '}} '+atGetParamValue('autotagsig'); if(atGetParamValue('autotagpre')=='1') document.editform['wpPreview'].click; else document.editform['wpSave'].click; //commented during testing to avoid accidents } if(location.href.indexOf("withautotag=tag")!=-1) {   var oldcontents=document.editform.wpTextbox1.value; document.editform.wpSummary.value=atGetParamValue('autotagsum'); document.editform.wpTextbox1.value='{'+'{'+atGetParamValue('autotagdp'); var atf=atGetParamValue('autotagflag'); //Don't newline after the tag, to prevent potential newline problems if(atf=='0') document.editform.wpTextbox1.value+='}}'+oldcontents; if(atf=='1') document.editform.wpTextbox1.value+='|'+atGetParamValue('autotag-n')+'}}'+oldcontents; if(atGetParamValue('autotagpre')=='1') document.editform['wpPreview'].click; else document.editform['wpSave'].click; //commented during testing to avoid accidents } })

//The new AutoTag: Place an AutoTag tab on the tab bar $(function { //Don't show on history, special, diff, or old revisions pages if (location.href.indexOf("action=history") == -1 && location.href.indexOf("action=raw") == -1 && location.href.indexOf("oldid=") == -1 && location.href.indexOf("action=submit") == -1 && location.href.indexOf("Special:") == -1 && location.href.indexOf("Special%3A") == -1) { var atmenu;  atmenu=document.createElement("DIV");  addTab("javascript:showatmenu","AutoTag","ca-autotag","AutoTag","");  atmenu.id="atmenu";  //This may need to change if siteSub's location is changed; it locates the correct  //position for the AutoTag menu to appear (just after the page title, where a tag //would appear). document.getElementById("siteSub").insertBefore(atmenu);  atmenu.style.display="none";  if(location.href.indexOf("showatmenu=true") != -1) atmenu.style.display="block";  var atmenuhtm="No AutoTag available for this sort of page.";  if(location.href.indexOf("User_talk:") != -1 || location.href.indexOf("User_talk%3A") != -1)  {    //User Talk namespace    var rownum=1;    var userwarnmatrix= //Format // Title0|Title1|Title2-3|Title4 // Description: template0 template1 |template2 ~template3 template4 blockingpage\n // Precede a template with | if a -n version is available and ~ if it automatically // includes a sig. If the template is itself -n, precede with !. If no template is // available, use X. "Please discuss your changes|Please use the sandbox|Warning|Final warning|"+ "Testing / Generic vandalism (additions): |test0 |test1 |test2 |test3 |test4 AIV\n"+ "Please discuss your changes|Please use the sandbox|Warning|Final warning|"+ "Testing / Generic vandalism (removals): X |test1a |test2a |test3a test4a AIV\n"+ "Please discuss your changes|Please use the sandbox|Warning|Final warning|"+ "Testing / Generic vandalism (page creation): X |test1article |test2article |test3article |test4article AIV\n"+ "X|Please use the sandbox|X|X|"+ "Self-reverted testing: X |test-self X X X X\n"+ "X|Please use the sandbox|Vandalism|Only warning|"+ "Obvious vandalism: X |vw X |bv |test4im AIV\n"+ "X|Please use the sandbox|Warning|Final warning|"+ "Blanking entire pages: X |blank1 |blank2 |blank3 |blank4 AIV\n"+ "Please discuss your page-moves|X|Page-move warning|Final warning|"+ "Renaming pages: |mp0 X |mp2 |mp3 |mp4 AIV\n"+ "X|Please don\\'t add commercial links|Spam warning|Final spam warning|"+ "Spamming: X |spam1 |spam2 |spam3 |spam4 AN/I\n"+ "Be careful with other user's userpages|Be careful with other user's userpages|Userpage vandalism warning|Final userpage vandalism warning|"+ "Userpage vandalism: |tpv0 |tpv1 |tpv2 |tpv3 |tpv4 AIV\n"+ "Please don\\'t remove warnings|Please don\\'t remove warnings|Warning removal|Final warning removal warning|"+ "Removing warnings: wr0 wr1 X wr3 wr4 RPP\n"+ "Neutral point of view|X|Adding personal analysis|Final NPOV warning|"+ "Non-neutral point of view: |NPOV0 X |comment2 |comment3 |comment4 AN/I\n"+ "X|Notability problems; this article may be deleted|X|X|"+ "Notability problems: X !nn-warn X X X X\n"+ "X|Please be careful with copyright|Copyright violations|X|"+ "Copyvio: X !nothanks X !usrcvtext X AN/I\n"+ "X|X|3RR warning|3RR warning|"+ "3RR violations: X X X |3RR 3RR4 AN3\n"+ "About censorship|X|Censorship warning|X|"+ "Censoring: Not_censored X X Not_censored_2 X AN/I\n"+ "X|X|Factual error warning|Final factual error warning|"+ "Adding factual errors: X X |verror2 verror3 verror4 AN/I\n"+ "X|X|Please stay on-topic|X|"+ "Adding off-topic content: X X mess2 X X X\n"+ "X|Humour|Humour warning|Final humour warning|"+ "Inappropriate humour: X |behave X ~funnybut seriously AN/I\n"+ "The Manual of Style|X|Manual of Style warning|X|"+ "Contravening the MOS: mos0 X mos2 mos3 X AN/I\n"+ "X|X|Please don\\'t reformat dates|X|"+ "Reformatting dates: X X dates2 dates3 X AN/I\n"+ "About US/UK English|X|US/UK English warning|Final US/UK English warning|"+ "US/UK English changes: lang0 X lang2 lang3 lang4 AN/I\n"+ "X|X|Articles about royalty|Final warning about royalty|"+ "Royalty stylistic problems: X X rn2 rn3 rn4 AN/I\n"+ "Please use your userpage|Article moved to your userspace|X|X|"+ "Userpage in article space: vanity userfy_warning X X X X\n"+ "X|Please use edit summaries|X|X|"+ "Missing edit summaries: X summary X X X X\n"+ "X|Sign your posts on talk pages|Sign your posts on talk pages|X|"+ "No talk-page signature: X talk_sign sign X X X\n"+ "X|Adding images to articles|Image use warning|Final image use warning|"+ "Adding inappropriate images to pages: X image1 image2 image3 image4 AIV\n"+ "X|X|Overwriting images|X|"+ "Overwriting images inappropriately: X X X imageow3 X AIV\n"+ "Image copyright|X|X|Final image copyright warning|"+ "Image copyright problems: image_copyright X X X insertimage4 AN/I\n"+ "X|X|Personal attack warning|Final personal attack warning|"+ "Personal attacks: X X |npa2 |npa3 |npa4 PAIN\n"+ "X|X|X|Defamation: only warning|"+ "Defamation: X X X X defwarn PAIN\n"+ "X|Please assume good faith|Assuming good faith warning|X|"+ "Assuming bad faith: X agf1 X agf3 X AN/I\n"+ "X|Please try to stay civil|Incivility warning|X|"+ "Incivility: X |civil1 |civil2 X X X\n"+ "X|X|X|X|"+ "Inappropriate username: X X X X X AIV\n"+ "X|X|X|Posting other user\\'s personal info: only warning|"+ "Posting other users' personal info: X X X X pinfo4 PAIN\n"+ "X|X|Don\\'t make legal threats|Legal threats:final warning|"+ "Legal threats: X X threat2 X threat4 AN/I\n"+ "X|Don\\'t remove AfD templates|AfD template removal warning|Final AfD template removal warning|"+ "Removing AfD templates: X drmafd drmafd2 drmafd3 drmafd4 AIV\n"+ "X|Don\\'t remove speedy-delete templates|Speedy-delete template removal warning|Final speedy-delete template removal warning|"+ "Removing speedy templates: X drmspeedy drmspeedy2 drmspeedy3 drmspeedy4 AIV\n"+ "X|Don\\'t remove maintenance notices|X|X|"+ "Removing maintenance notices: X drmmt X X X X\n"+ "X|Don\\'t recreate deleted articles|X|X|"+ "Recreating deleted articles: X recreated X X X X\n"+ "";   atmenuhtm=" " } else { //not the User Talk namespace atmenuhtm=" "; } atmenu.innerHTML=atmenuhtm; } }); //