User:WOSlinker/common.js

/* if(mw.config.get('wgAction') == 'edit') { document.getElementById('wpSummary').value='tidy listings'; document.getElementById('wpMinoredit').checked = true; } //mw.loader.load( '/w/index.php?title=User:WOSlinker/findparameterdups.js&action=raw&ctype=text/javascript' );

//Useful scripts //Add a 'null edit' tab if(mw.config.get('wgNamespaceNumber') != -1 && mw.config.get('wgArticleId') != 0) { $( function nullEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',nulledit:true}), 'null', 'p-null', 'Null edit this page');   } )} if(mw.config.get('wgAction') == 'edit' && queryString('nulledit') == 'true') { $(function nullEdit {       document.getElementById('wpSave').click;    } )} function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }   return null; }

function phonecode_queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }   return null; } $( function phonecodeEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',phonecode:true}), 'phonecode', 'p-phonecode', 'phonecode edit'); }) if(mw.config.get('wgAction') == 'edit' && phonecode_queryString('phonecode') == 'true') { var myContent = document.getElementById('wpTextbox1').value; myContent = myContent.replace(/\{\{RelatedWikipedia\|.*?\}\}\n/g,''); myContent = myContent.replace(/\{\{RelatedCommonsCat\|.*?\}\}\n/g,'');

if (myContent != document.getElementById('wpTextbox1').value) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='remove RelatedWikipedia & RelatedCommonsCat templates as not needed anymore, links done by wikidata'; document.getElementById('wpMinoredit').checked = true; } }

$( function flagEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',flag:true}), 'flag', 'p-flag', 'flag edit'); }) if(mw.config.get('wgAction') == 'edit' && phonecode_queryString('flag') == 'true') { var myContent = document.getElementById('wpTextbox1').value; // myContent = myContent.replace(/\[\[Image\:Flag of the /g,'{{flag|'); // myContent = myContent.replace(/\[\[File\:Flag of the /g,'{{flag|'); // myContent = myContent.replace(/\[\[Image\:Flag of /g,'{{flag|'); // myContent = myContent.replace(/\[\[File\:Flag of /g,'{{flag|'); //myContent = myContent.replace(/http\:\/\/book\.bestwestern\.com\/bestwestern\/productInfo\.do\?propertyCode\=(\d*) /g,'https://www.bestwestern.com/content/best-western/en_US/booking-path/hotel-details.$1.html '); //myContent = myContent.replace(/http\:\/\/book\.bestwestern\.com\/bestwestern\/productInfo\.do\?propertyCode\=(\d*)\|/g,'https://www.bestwestern.com/content/best-western/en_US/booking-path/hotel-details.$1.html|'); //myContent = myContent.replace(/http\:\/\/www\.bestwestern\.com\/prop\_(\d*) /g,'https://www.bestwestern.com/content/best-western/en_US/booking-path/hotel-details.$1.html '); //   myContent = myContent.replace(/http\:\/\/book\.bestwestern\.com/g,'https://book.bestwestern.com'); //   myContent = myContent.replace(/http\:\/\/www\.bestwestern\.com/g,'https://www.bestwestern.com'); myContent = myContent.replace(/(\| *imagesize[0-9a-z]* *\= *[0-9]*)px/g,'$1');

myContent = myContent.replace(/‎/g,''); //note: there is a hidden unicode character in this replace

if (myContent != document.getElementById('wpTextbox1').value) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='fix image params'; document.getElementById('wpMinoredit').checked = true; } }

$( function ampmEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',ampm:true}), 'ampm', 'p-ampm', 'ampm edit'); }) if(mw.config.get('wgAction') == 'edit' && phonecode_queryString('ampm') == 'true') { var myContent = document.getElementById('wpTextbox1').value; myContent = myContent.replace(/\:00[ ]*a\.m\./g,'AM'); myContent = myContent.replace(/\:00[ ]*p\.m\./g,'PM'); myContent = myContent.replace(/\:00[ ]*am/g,'AM'); myContent = myContent.replace(/\:00[ ]*pm/g,'PM'); myContent = myContent.replace(/\:00[ ]*A\.M\./g,'AM'); myContent = myContent.replace(/\:00[ ]*P\.M\./g,'PM'); myContent = myContent.replace(/\:00[ ]*AM/g,'AM'); myContent = myContent.replace(/\:00[ ]*PM/g,'PM'); myContent = myContent.replace(/[ ]*a\.m\./g,'AM'); myContent = myContent.replace(/[ ]*p\.m\./g,'PM'); myContent = myContent.replace(/[ ]*A\.M\./g,'AM'); myContent = myContent.replace(/[ ]*P\.M\./g,'PM');

if (myContent != document.getElementById('wpTextbox1').value) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='AM/PM as per wv:Times'; document.getElementById('wpMinoredit').checked = true; } }