User:Cleared as filed/wikipageAfd.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:Cleared as filed/wikipageAfd. |
// User:Quarl/wikipageAfd.js - extra afd-related wikipage functionality
// requires: wikipage.js, datetime.js
// <pre><nowiki>
// return log page for given date (default today)
function afdLogPage(d) {
d = d || new Date();
return new WikiPage(null,'Wikipedia:Articles for deletion/Log/' + datestampYYYYMonthD(d));
}
WikiPage.prototype.afdPage = function() {
// AFD only applies to main (ignoring Talk)
if (!this.nsMainP) return null;
return new WikiPage(null, 'Wikipedia:Articles for deletion/' + this.article);
}
WikiPage.prototype.afdPageX = function() {
// already an AFD page?
if (this.afdTargetPage()) return this;
return this.afdPage();
}
WikiPage.prototype.afdTargetPage = function() {
if (!this.page.match(/^Wikipedia:Articles for deletion\/(.*?)(?: \([0-9]+|2nd nomination|3rd nomination|4th nomination\))?$/)) return null;
var p = RegExp.$1;
if (p.match(/^Log\//)) return null;
return new WikiPage(null, p);
}
WikiPage.prototype.afdLogDate = function() {
if (!this.page.match(/^Wikipedia:Articles for deletion\/Log\/(.*?)?$/)) return null;
var d = RegExp.$1;
return new Date(Date.parse(d));
}
function wikipageAfd_load() {
window.wpAfdTarget = wikiPage.afdTargetPage();
window.wpAfd = wikiPage.afdPageX();
window.wpAfdLogDate = wikiPage.afdLogDate();
window.afdP = Boolean(wpAfdTarget);
window.afdLogP = Boolean(wpAfdLogDate);
}
$(wikipageAfd_load);
// </nowiki></pre>