User:WOSlinker/musartist.js

function musartist_queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }   return null; } if(mw.config.get('wgNamespaceNumber') != -1 && mw.config.get('wgArticleId') != 0) { $( function musartistEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',musartist:true}), 'musartist', 'p-musartist', 'MusArtist edit this page');   } )} String.prototype.trim = function { return this.replace(/^\s+|\s+$/g,""); }

String.prototype.right = function(n) { return this.substring(this.length, this.length - n) }

if(mw.config.get('wgAction') == 'edit' && musartist_queryString('musartist') == 'true') { $(function rugbyEdit {

var sep = '\n';

var idx_start; var idx_end; var removed;

var myContent = document.getElementById('wpTextbox1').value; var idx1 = myContent.indexOf("=="); if (idx1 == -1) { idx1 = myContent.length; }

var myContentTop = myContent.substring(0,idx1); var myContentBottom = myContent.substring(idx1,99999999);

function findparam(param,removeit) {   re = new RegExp("\\|\\s*" + param + "\\s*="); var m = re.exec(myContentTop); try { idx_start = m.index; var idx_equals = myContentTop.indexOf("=", idx_start); idx_end = myContentTop.indexOf(sep, idx_start); var result = myContentTop.substring(idx_equals+1,idx_end).trim; return result; } catch (e) { return ""; } } /* var Born = findparam("Born"); var Died = findparam("Died");

if (Born.substring(0,1) == "{" && Born.right(1) == "}") { myContentTop = myContentTop.replace(/\n\|Born\s*=/,'\n|birth_date ='); myContentTop = myContentTop.replace(/\n\|\s*Born\s*=/,'\n| birth_date ='); } if (Died.substring(0,1) == "{" && Died.right(1) == "}") { myContentTop = myContentTop.replace(/\n\|Died\s*=/,'\n|death_date ='); myContentTop = myContentTop.replace(/\n\|\s*Died\s*=/,'\n| death_date ='); }

myContent = myContentTop +myContentBottom;

myContentTop = myContentTop.replace(/\|\s*image_size\s*=\s*<--!Only for images smaller than 220px! -->\s*\n/,''); myContent = myContentTop +myContentBottom;

if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='remove invalid html comment from image_size'; document.getElementById('wpMinoredit').checked = true; };

} )}