User:Thetrick/tfd helper/script.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.

//<pre><nowiki>
 
/************* tfd Helper ************/
// see User:Thetrick/tfd_helper
// based on afd_helper
 
//importScript("User:Thetrick/tfd_helper/autmod.js");
importScript("User:Jnothman/automod.js");
 
tfdh_signature = '~~'+'~';
 
function tfd_helper() {
    if (auto_mod())
       return;
 
    if (am_get_title().indexOf('Template:') != -1)
        am_add_li('tb', 'javascript:tfd_nominate()', 'Nominate TfD', '', 'Nominate this template for deletion');
}
 
function tfd_nominate() {
    var title = am_get_title();
    var shorttitle = title.replace(/Template:/, "");
    var log_date = window.prompt("This should be the date of the latest TfD log. Change it if necessary.", am_guess_date());
    if (!log_date)
        return;
    var reason = window.prompt("Please justify your TfD nomination of "+title+":");
    if (!reason)
        return;
 
//open the template in a new page - crude but works
    window.open(am_make_url(title, '<noinclude>{{'+'tfd|{{subst:PAGENAME}}}}</noinclude>', '', 'nomination for [[WP:TfD|deletion]]'), 'tfdhn1');
 
//open log in new page 
    window.open(am_make_url('Wikipedia:Templates for deletion/Log/'+log_date, '', '{{'+'subst:tfd2|'+shorttitle+'|text='+reason+' '+tfdh_signature+" ~~"+"~~"+"~"+'}}', 'Nominating [['+title+']] for deletion') + "&amatstring=-->", 'tfdhn2');
 
}
 
addOnloadHook(tfd_helper);
 
//</nowiki></pre>