User:Mike Dillon/Scripts/convert-svtopics.js

$(function {    var langTopicRegex = new RegExp( '\\{\\{(' + getLanguageCodes.join('|') + ')-([\\w\\s]+)\\}\\}', 'g');

var textBox = document.getElementById('wpTextbox1'); if (!textBox) return; if (!textBox.value.match(langTopicRegex)) return; if (textBox.value.match(/addOnloadHook/)) return;

var summary = document.getElementById('wpSummary'); var minor = document.getElementById('wpMinoredit'); var diff = document.getElementById('wpDiff'); if (!summary || !minor || !diff) return;

var li = mw.util.addPortletLink("p-tb", "#", "Replace topic labels", "ca-langtopics", "Replace language-specific label templates with standard templates"); var a = li.getElementsByTagName("a")[0]; a.onclick = function { textBox.value = textBox.value.replace(langTopicRegex, '');

summary.value += 'use standard label templates instead of language-specific templates'; minor.click; diff.click;

return false; }; });