User:Smith609/citations dev.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. |
This user script seems to have a documentation page at User:Smith609/citations dev. |
// @Version 1.00 - Adds a "Citation bot" link to the toolbox, and a button beneath edit fields.
// @Version 1.01 - Sets accept-charset to avoid mangling special characters
function addCBetaToToolbox() {
if (mw.config.get('wgCanonicalNamespace') != "Special") {
var pTb = document.getElementById("p-tb");
if( !pTb ) return;
var escPageName = encodeURIComponent(mw.config.get('wgPageName'));
mw.util.addPortletLink("p-tb", "http://tools.wmflabs.org/citations-dev/doibot.php?edit=toolbar&slow=1&user="+encodeURIComponent(mw.config.get('wgUserName'))+"&page="+escPageName, 'Expand citations [Beta]', '', "Expand citations and fix common formatting errors");
}
}
// Add a citation bot button
function addCitationBeta() {
if (document.getElementById('wpDiff')){
var diff = document.getElementById('wpDiff');
var cbetaButton = document.createElement("input");
cbetaButton.value="Citations [Beta]";
cbetaButton.type="submit";
originalAction=document.getElementById('editform').getAttribute('action');
cbetaButton.setAttribute("onmousedown", " document.getElementById('editform').setAttribute('action', 'http://tools.wmflabs.org/citations-dev/text.php')");
cbetaButton.setAttribute("onkeydown", " document.getElementById('editform').setAttribute('action', 'http://tools.wmflabs.org/citations-dev/text.php')");
// document.getElementById('editform').setAttribute('accept-charset', 'UTF-8');
diff.setAttribute("onmousedown", originalAction);
diff.setAttribute("onkeydown", originalAction);
document.getElementById('wpPreview').setAttribute("onmousedown", originalAction);
document.getElementById('wpPreview').setAttribute("onkeydown", originalAction);
document.getElementById('wpSave').setAttribute("onmousedown", originalAction);
document.getElementById('wpSave').setAttribute("onkeydown", originalAction);
diff.parentNode.insertBefore(cbetaButton, diff.nextSibling);
}
}
$(addCitationBeta);
var skin = mw.config.get('skin');
if( skin == "myskin" || skin == "simple" || skin == "monobook" || skin == "modern" || skin == "chick" || skin == "vector") {
$(addCBetaToToolbox);
}