User:Graeme Bartlett/monobook.js

//importScript ('User:Graeme Bartlett/js/afc-helper.js'); // Add custom Character Inserter entries window.charinsertCustom = { "Wiki markup": ' α β Γ γ μm π Δ Π Σ Å + \n==References==\n{\{Reflist}}\n', "Chem": ' – — ° ′ ″ ≈ ≠ ≤ ≥ ± − × ÷ ← → ↔ ⇌ ⇄ ↑ ↓ ∠ · • ≡ § α β γ δ η θ λ+ σ ω μm π Γ Δ Π Σ Å cm−1     +  +  [\[+]]  +  {\{Reflist}}     +  +   +   + \n==References==\n{\{Reflist}}\n  [' + '[Category:+]]   #REDIRECT+  :*{\{subst:UND|g13}}.\  {\{pp-semi|small=yes}}  |.CASNo_Ref.=.{\{Cascite|changed|CAS}}  |.GHS_ref=\n|.GHSPictograms.=.{\{GHS07}}\n|.GHSSignalWord.=.Warning\n|.HPhrases.=.{\{H-phrases|}}\n|.PPhrases.=.{\{P-phrases|}}  {\{Chembox\n|Section1={\{Chembox.Identifiers\n.}}\n|Section2={\{Chembox.Properties\n.}}\n|Section8={\{Chembox.Related\n.}}\n}}\n ', "Moss": ' → + {\{Proper.name|+}} {\{lang|cs|+}} {\{lang|de|+}} {\{lang|en-emodeng|+}} {\{lang|es|+}} {\{lang|fr|+}} {\{lang|grc-Latn|+}} {\{lang|it|+}} {\{lang|la|+}} {\{lang|nl|+}} {\{lang|sv|+}} {\{lang|yue-jyutping|+}} {\{sic|nolink=y|reason=error.in.source|+}} {\{not.a.typo|+}} {\{DNA.sequence|+}} #REDIRECT+ {\{R.from.misspelling}}\n ', "Talks": ' {\{WP.Biography|living=yes|class=start|s&a-work-group=yes|s&a-priority=low}}\n {\{WP.Astronomy|object=yes|needs-infobox=no|class=stub|importance=low}}\n {\{WP.Chemicals|class=start|importance=low}}\n {\{WP.Geology|class=start|importance=low}}\n {\{WP.Physics|class=start|importance=low}}\n {\{WikiProject.Molecular.Biology|class=C|genetics=y}}\n ' }; /** * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor. * @see TemplateScript * @update-token /* mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js'); /** * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor. * @see https://meta.wikimedia.org/wiki/TemplateScript * @update-token */ // $.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function { pathoschild.TemplateScript.add({ name:'lower', script: function(editor) { editor.replaceSelection(function(selected) {		return selected.toLowerCase;   	}); } })}) $.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function { pathoschild.TemplateScript.add({ name:'title', script: function(editor) { editor.replaceSelection(function(selected) {		return selected.toLowerCase.replace(/(^[a-z]| [a-z]|-[a-z])/g, function($1){ return $1.toUpperCase; });   	});	} }); pathoschild.TemplateScript.add({ name:'P-phrasefmt', script: function(editor) { editor.replaceSelection(function(selected) {		return selected.replace(/, P/g,"|").replace(/, and P/,"|").replace(/P/g,"").replace(/103\|(.*)203/,"$1203").replace(/235\|(.*)413/,"$1413").replace(/235\|(.*)411/,"$1411").replace(/234\|(.*)236/,"$1236").replace(/ /g,"");   	}); } }); pathoschild.TemplateScript.add({ name:'H-phrasefmt', script: function(editor) { editor.replaceSelection(function(selected) {		return selected.replace(/H([0-9][0-9][0-9]).*/g,"|$1E").replace(/E\n\n*\|/g,"|").replace(/\|/,"").replace(/E/,"").replace(/314(.*)\|318/,"314$1").replace(/401(.*)\|411/,"401$1").replace(/402(.*)\|412/,"402$1").replace(/400\|(.*)410/,"$1410");   	}); } }); pathoschild.TemplateScript.add({ name:'whatlinksherebrak', script: function(editor) { editor.replaceSelection(function(selected) {		return selected.replace(/\[\[([^\]]*)\]\]/g,"$1 ");   	}); } }); pathoschild.TemplateScript.add({ name:'whatlinkshereraw', script: function(editor) { editor.replaceSelection(function(selected) {		return selected.replace(/[* ]*([^\]]*)/,"*$1 ");   	}); } }); pathoschild.TemplateScript.add({ name:'chemboxformat', script: function(editor) { editor.replaceSelection(function(selected) {		return selected.replace(/[23]\.3\.[1-9][0-9]* *UNII\n/,"| UNII = ").replace(/[23]\.3\.[1-9][0-9]* *EC Number\n/,"| EC_number = ").replace(/[23]\.3\.[1-9][0-9]* *European Community \(EC\) Number *\n/,"| EC_number = ").replace(/InChI=/,"| StdInChI=").replace(/[32]\.1\.[1-9][0-9]* *InChI *Key\n/,"| StdInChIKey = ").replace(/[23]\.3\.[1-9][0-9]* *CAS\n/,"| CASNo = ").replace(/CHEMBL([1-9][0-9]*)/,"| ChEMBL = $1").replace(/DB([0-9][0-9]*)/,"| DrugBank = DB$1").replace(/CHEBI:([1-9][0-9]*)/,"| ChEBI = $1").replace(/[23]\.1\.[1-9][0-9]* *Canonical SMILES\n/,"| SMILES = ").replace(/\n*ChemSpider[-\t]/,"| ChemSpiderID = ").replace(/ChemSpider ID/,"| ChemSpiderID = ").replace(/[23]\.3\.[1-9][0-9]* *RTECS Number\n/,"| RTECS = ").replace(/[23]\.3\.[1-9][0-9]* *UN Number\n/,"| UNNumber = ").replace(/New Window\n\n/g,"").replace(/DTXSID/,"| DTXSID = DTXSID").replace(/Computed by.*\n/g,""); });	} }); pathoschild.TemplateScript.add({	name:'addbullets',	script: function(editor) {		editor.replaceSelection(function(selected) { return selected.replace(/^\n/gm,"").replace(/^/gm,"*").replace(/^\*/gm,"* ").replace(/^\* */gm,"* "); });	} }

); });

//