Difference between revisions of "MediaWiki:ReplaceWordWithLink.js"
From Tycoon Gaming
Line 13: | Line 13: | ||
var output = save.replace(/' ' + list[i] + ' '/gi, ' ' + '<a href="/wiki/index.php/' + replacelist[i] + '">' + list[i] + '</a>' + ' '); | var output = save.replace(/' ' + list[i] + ' '/gi, ' ' + '<a href="/wiki/index.php/' + replacelist[i] + '">' + list[i] + '</a>' + ' '); | ||
console.log('Output: ' + output); | console.log('Output: ' + output); | ||
+ | console.log('Save: ' + save + '<br><br><br><br><br>' + save.replace(/' ' + list[i] + ' '/gi, ' ' + '<a href="/wiki/index.php/' + replacelist[i] + '">' + list[i] + '</a>' + ' ')) | ||
window.element.innerHTML = output; | window.element.innerHTML = output; | ||
} | } |
Revision as of 00:00, 12 October 2019
/*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); console.log('Save: ' + save + '<br><br><br><br><br>' + save.replace(/' ' + list[i] + ' '/gi, ' ' + '<a href="/wiki/index.php/' + replacelist[i] + '">' + list[i] + '</a>' + ' ')) window.element.innerHTML = output; } } else { } } Replace();