User:Paper9oll/FormatterTagger.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. User:Paper9oll/FormatterTagger. |
// <nowiki>
mw.config.set('userjs-templatescript', { regexEditor: false });
$.ajax("//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js", { dataType: "script", cache: true }).then(function () {
pathoschild.TemplateScript.add([
{
name: 'Formatter/Tagger',
tooltip: 'Formatting and tagging unreliable sources',
script: function (editor) {
runFunction(editor, 'all');
}
},
{
name: 'Tagger',
tooltip: 'Tagging unreliable sources',
script: function (editor) {
runFunction(editor, 'tagger');
}
},
{
name: 'Settings',
tooltip: 'Settings',
script: function () {
runSettings();
}
}
],
{
category: 'Paper9ollScripts',
forActions: 'edit',
forNamespaces: [0, 2, 118]
});
});
function loadScript(callback) {
if (mw.config.get('wgDBname') === 'enwiki') {
var script = document.createElement('script');
script.type = 'text/javascript';
var url = '//en.wikipedia.org/w/index.php?title=User:Paper9oll/FormatterTagger-core.js&action=raw&ctype=text/javascript';
var cacheBuster = 'cache=' + Date.now();
url += (url.indexOf('?') === -1 ? '?' : '&') + cacheBuster;
script.src = url;
script.onload = callback;
document.head.appendChild(script);
}
}
function runSettings() {
loadScript(function () {
init.checkVersion();
settings.settings();
});
}
function runFunction(editor, type) {
loadScript(function () {
init.checkVersion();
warning.user(editor);
warning.usageWarning().then(function () {
if (type !== 'tagger') {
logger.clear();
hatnotes.hatnotes(editor);
typography.typography(editor);
infobox.infobox(editor);
wikitable.wikitable(editor);
template.template(editor);
efn.format(editor);
cite.cite(editor);
}
if (type === 'tagger' || type === 'all') {
unreliableSource.KO(editor);
unreliableSource.RSP(editor);
}
if (type === 'all') {
editSummary.auto(editor);
}
else if (type === 'tagger') {
editSummary.tagger(editor);
}
});
});
}
// </nowiki>