„Benutzer:P.Copp/scripts/adddeletereason.js“ – Versionsunterschied
Erscheinungsbild
Inhalt gelöscht Inhalt hinzugefügt
PDD (Diskussion | Beiträge) +mwl |
Hgzh (Diskussion | Beiträge) fix wpReason |
||
Zeile 1: | Zeile 1: | ||
if (mw.config.get('wgAction')==='delete') { |
if (mw.config.get('wgAction')==='delete') { |
||
function addDeleteReason(res) { |
function addDeleteReason(res) { |
||
var wpReason = document. |
var wpReason = document.getElementsByName('wpReason')[0]; |
||
if (!wpReason) return; |
if (!wpReason) return; |
||
// für Skripte und Links, die automatisch eine Löschbegründung eintragen |
// für Skripte und Links, die automatisch eine Löschbegründung eintragen |
||
Zeile 17: | Zeile 17: | ||
$(document).ready(function () { |
$(document).ready(function () { |
||
if (!document. |
if (!document.getElementsByName('wpReason')[0]) return; |
||
try {mw.loader.load(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&callback=addDeleteReason&format=json&prop=revisions&rvprop=content&rvlimit=1&pageids=' + mw.config.get('wgArticleId'));} |
try {mw.loader.load(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&callback=addDeleteReason&format=json&prop=revisions&rvprop=content&rvlimit=1&pageids=' + mw.config.get('wgArticleId'));} |
||
catch (e) {return;} |
catch (e) {return;} |
Version vom 20. Juni 2023, 15:00 Uhr
if (mw.config.get('wgAction')==='delete') {
function addDeleteReason(res) {
var wpReason = document.getElementsByName('wpReason')[0];
if (!wpReason) return;
// für Skripte und Links, die automatisch eine Löschbegründung eintragen
if (location.search.indexOf('wpReason=') > -1) return;
var text = '';
if (res && res.query && res.query.pages)
for (var i in res.query.pages)
if (res.query.pages[i].revisions)
text = res.query.pages[i].revisions[0]['*'].substr(0,400).replace(/\n/g,' ');
var regexp = /(\{\{(?:SLA|Löschen|delete)[^\}]*\}\}(.*(?:MES?Z\)|CES?T\)|(?:REDIRECT|WEITERLEITUNG)[^\]]*\]\]))?)/i;
var match = regexp.exec(text);
wpReason.value = match ? match[1] : "";
}
$(document).ready(function () {
if (!document.getElementsByName('wpReason')[0]) return;
try {mw.loader.load(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&callback=addDeleteReason&format=json&prop=revisions&rvprop=content&rvlimit=1&pageids=' + mw.config.get('wgArticleId'));}
catch (e) {return;}
});
}