Revision as of 23:57, 11 October 2019 by Donald (talk | contribs)

MediaWiki:ReplaceWordWithLink.js

From Tycoon Gaming

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/*Search Word*/
var list = ['Job Center', 'Grand Exchange', 'ATC',  'car dealership', 'job', 'skill', 'trucker', 'garage', 'strength'];
/*Replace Word (Link)*/
var replacelist = ['Job_Center', 'Grand_Exchange', 'Airline_Pilot#ATC_.28Air_Traffic_Control.29', 'Car_Dealer', 'Job_Center', 'Skill_Level_Tokens', 'Trucking', 'Garage', 'Strength'];
var edit = -1;
function Replace(){
	var path = window.location.search;
	edit = path.search('&action=edit');
	if (edit == -1){
		for (var i = 0; i < list.length; i++){
			window.element = document.getElementById("bodyContent");
			var save = window.element.innerHTML;
			var output = save.replace(/' ' + list[i] + ' '/gi, ' ' + '<a href="/wiki/index.php/' + replacelist[i] + '">' + list[i] + '</a>' + ' ');
			console.log('Output: ' + output);
			window.element.innerHTML = output;
		}
	} else {
	}
}
Replace();