User:Zackmann08/chembox-replace.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:Zackmann08/chembox-replace. |
jQuery(document).ready(function($) {
if(mw.config.get('wgNamespaceNumber') != -1) {
mw.loader.using(['mediawiki.util']).done( function() {
var portletlink = mw.util.addPortletLink('p-tb','#','Chembox replace','t-chembox-replace');
$(portletlink).click(function(e) {
e.preventDefault();
chemboxReplace();
});
});
}
function chemboxReplace() {
var myContent = document.getElementById('wpTextbox1').value;
var mysummary = "converting to use [[Template:Infobox chemical]]";
var text = document.getElementById('wpTextbox1').value;
// {{Chembox Identifiers}}
// {{Chembox Properties}}
// {{Chembox Structure}}
// {{Chembox Thermochemistry}}
// {{Chembox Explosive}}
// {{Chembox Pharmacology}}
// {{Chembox Hazards}}
// {{Chembox Related}}
text.replace(/{{\s*Chembox Identifiers/i, "{{Infobox chemical/identifiers");
text.replace(/{{\s*Chembox Properties/i, "{{Infobox chemical/properties");
text.replace(/{{\s*Chembox Structure/i, "{{Infobox chemical/structure");
text.replace(/{{\s*Chembox Thermochemistry/i, "{{Infobox chemical/thermochemistry");
text.replace(/{{\s*Chembox Explosive/i, "{{Infobox chemical/explosive");
text.replace(/{{\s*Chembox Pharmacology/i, "{{Infobox chemical/pharmacology");
text.replace(/{{\s*Chembox Hazards/i, "{{Infobox chemical/hazards");
text.replace(/{{\s*Chembox Related/i, "{{Infobox chemical/related");
text.replace(/{{\s*Chembox/i, "{{Infobox chemical");
//document.getElementById('wpTextbox1').value;
document.getElementById('wpSummary').value = "Tagging page for conversion";
document.getElementById('wpTextbox1').value = text;
}
});