Jump to content

User:Aktsu/mostm.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//The MMA WP:MOSTM fixer
//Changes capitalization to comply with WP:MOSTM for PRIDE, DREAM, SHOOTO, DEEP and HERO's

/*
To use add;
importScript('User:Aktsu/mostm.js'); 
to your monobook.js (http://en.wikipedia.org/wiki/Special:MyPage/monobook.js).
*/

//Always double check what the script does, and manually move pages not already moved.
//If you know what you're doing, you're welcome to improve the script. If you don't, message me with suggestions and I'll try to implement them.

//NOTES:
//- It DOES NOT differ between normal links and interwiki-links, so whose have to be changed back to how they were manually (unless you intend to move those pages as well).

function mostm(){
 var txt=document.editform.wpTextbox1;
 txt.value=txt.value.replace(/\[\[PRIDE\|PRIDE Fighting Championships\]\]/g, '[[Pride Fighting Championships]]');
 txt.value=txt.value.replace(/\[\[PRIDE\|/g, '[[Pride Fighting Championships|');
 txt.value=txt.value.replace(/\[\[DREAM\]\]/g, '[[Dream (mixed martial arts)|Dream]]');
 txt.value=txt.value.replace(/\[\[PRIDE\]\]/g, '[[Pride Fighting Championships|Pride]]');
 txt.value=txt.value.replace(/DREAM.1/g, 'Dream 1');
 txt.value=txt.value.replace(/DREAM.2/g, 'Dream 2');
 txt.value=txt.value.replace(/DREAM.3/g, 'Dream 3');
 txt.value=txt.value.replace(/DREAM.4/g, 'Dream 4');
 txt.value=txt.value.replace(/DREAM.5/g, 'Dream 5');
 txt.value=txt.value.replace(/DREAM.6/g, 'Dream 6');
 txt.value=txt.value.replace(/DREAM.7/g, 'Dream 7');
 txt.value=txt.value.replace(/PRIDE/g, 'Pride');
 txt.value=txt.value.replace(/DREAM/g, 'Dream');
 txt.value=txt.value.replace(/HERO\'s/g, 'Hero\'s');
 txt.value=txt.value.replace(/HERO\'S/g, 'Hero\'s');
 txt.value=txt.value.replace(/HEROs/g, 'Hero\'s');
 txt.value=txt.value.replace(/HEROS/g, 'Hero\'s');
 txt.value=txt.value.replace(/SHOOTO/g, 'Shooto');
 txt.value=txt.value.replace(/DEEP/g, 'Deep');
 txt.value=txt.value.replace(/RINGS/g, 'Rings');

 edit_summary_mostm()
}

//Stolen from User:Lightmouse/monobook.js/script.js
function edit_summary_mostm(){
// Add a tag to the summary box
 var txt=document.editform.wpSummary;
    var summary = "[[User:Aktsu/mostm.js|script]]-assisted [[WP:MOSTM]] fixes; ";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
   document.editform.wpDiff.click();
}

$(function () {
 if(document.forms.editform) {
  mw.util.addPortletLink('p-tb', 'javascript:mostm()', 'MMA MOSTM fixer', '', '', '', '');
  }
});