Jump to content

User:UserB/monobook.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
m Maintenance: Fixing deprecated call to addPortletLink (mw:ResourceLoader/Migration_guide_(users)#addPortletLink)
 
(One intermediate revision by the same user not shown)
Line 140: Line 140:


// History tools
// History tools
mw.loader.load(
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/enwiki/w/index.php?title=User:Voice_of_All/History/monobook.js'
'https://en.wikipedia.org/enwiki/w/index.php?title=User:Voice_of_All/History/monobook.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
+ '&action=raw&ctype=text/javascript&dontcountme=s');


//
//
Line 154: Line 154:
if (!(url = x.getElementsByTagName('a')[0] )) return;
if (!(url = x.getElementsByTagName('a')[0] )) return;
if (!(url = url.href )) return;
if (!(url = url.href )) return;
var y = addPortletLink('p-cactions', url+"&section=0", '0', 'ca-edit-0',
var y = mw.util.addPortletLink('p-cactions', url+"&section=0", '0', 'ca-edit-0',
'Edit the lead section of this page', '0', x.nextSibling);
'Edit the lead section of this page', '0', x.nextSibling);



Latest revision as of 16:27, 27 February 2022

/*
__NOTOC__
==function getPname()==

* This function is required for [[User:Howcheng/quickimgdelete.js|Howcheng's image deletion script]].

<pre>*/
function getPname() {
  z=document.getElementById("content").childNodes;
  for (var n=0;n<z.length;n++) { 
    if (z[n].className=="firstHeading") {
      var text = z[n].textContent ? z[n].textContent : z[n].innerText;
      return text;
    }
  }
}
/*
</pre>

==function addLink()==

*This function will add a link to your Wikipedia toolbar.  It is required both for [[User:Howcheng/quickimgdelete.js|Howcheng's image deletion script]] and my template replacement script.

<pre>
*/

/* This code may be problematic when it comes to titles with ampersands, etc, which are stored as ''& amp ;'' in HTML (without the spaces).
  A solution that solves this is the following:
    return document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free'));
*/

function addLink(where, url, name, id, title, key, after){
    //* where is the id of the toolbar where the button should be added;
    //   i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
    //
    //* url is the URL which will be called when the button is clicked.
    //   javascript: urls can be used to do more complex things.
    //
    //* name is what will appear as the name of the button.
    //
    //* id is the id of the button; it's best to define one.  
    //   Use a prefix to make sure its unique. Optional.
    //
    //* title is the tooltip title that gives a longer description 
    //   of the button; if you define a accesskey, mention it here. Optional.
    //
    //* key is the char you want for the accesskey. Optional.
    //
    //* after is the id of the button you want to follow this one. Optional.
    //
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
        tabs.insertBefore(li,document.getElementById(after));
    } else {
        tabs.appendChild(li);
    }
    if(id) {
        if(key && title) { ta[id] = [key, title]; }
        else if(key) { ta[id] = [key, '']; }
        else if(title) { ta[id] = ['', title];} 
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}

function ReplaceDeletedTemplate_onload()
{
addLink('p-tb', 'http://en.wikipedia.org/wiki/User_talk:B/page', 'My user page', 'temp-bp', 'My user page');
addLink('p-tb', 'http://en.wikipedia.org/wiki/User_talk:B/page2', 'Working page', 'temp-bp2', 'Working page');
addLink('p-tb', 'http://en.wikipedia.org/wiki/Category:Candidates_for_speedy_deletion?action=purge#Pages_in_category', 'CAT:CSD', 'temp-csd', 'CAT:CSD');
addLink('p-tb', 'http://en.wikipedia.org/wiki/Category:Attack_pages_for_speedy_deletion?action=purge#Pages_in_category', 'CAT:ASD', 'temp-asd', 'CAT:ASD');
addLink('p-tb', 'http://en.wikipedia.org/wiki/Category:Nonsense_pages_for_speedy_deletion?action=purge#Pages_in_category', 'CAT:NSD', 'temp-nsd', 'CAT:NSD');
addLink('p-tb', 'http://en.wikipedia.org/wiki/Category:Non-commercial_use_only_images_for_speedy_deletion?action=purge#Pages_in_category', 'CAT:NCSD', 'temp-ncsd', 'CAT:NCSD');
addLink('p-tb', 'http://en.wikipedia.org/wiki/Wikipedia:Files_for_deletion?action=purge', 'WP:IFD', 'temp-ifd', 'WP:IFD');
addLink('p-tb', 'http://en.wikipedia.org/wiki/Wikipedia:Templates_for_deletion?action=purge', 'WP:TFD', 'temp-tfd', 'WP:TFD');
addLink('p-tb', 'http://en.wikipedia.org/wiki/Wikipedia:Miscellany_for_deletion?action=purge', 'WP:MFD', 'temp-mfd', 'WP:MFD');
addLink('p-tb', 'http://en.wikipedia.org/wiki/Wikipedia:Deletion_review?action=purge', 'WP:DRV', 'temp-mfd', 'WP:DRV');
addLink('p-tb', 'http://en.wikipedia.org/wiki/Wikipedia:Requests_for_adminship?action=purge', 'WP:RFA', 'temp-rfa', 'WP:RFA');
addLink('p-tb', 'http://en.wikipedia.org/enwiki/w/index.php?title=Wikipedia:Usernames_for_administrator_attention&action=purge', 'WP:UAA', 'temp-uaa', 'WP:UAA');
addLink('p-tb', 'http://en.wikipedia.org/enwiki/w/index.php?title=Wikipedia:Administrators%27_noticeboard/Incidents&action=purge', 'WP:ANI', 'temp-ani', 'WP:ANI');
addLink('p-tb', 'http://en.wikipedia.org/enwiki/w/index.php?title=Wikipedia:Administrators%27_noticeboard/Edit_warring&action=purge', 'WP:AN3', 'temp-an3', 'WP:AN3');
addLink('p-tb', 'http://en.wikipedia.org/enwiki/w/index.php?title=Category:Requests_for_unblock&action=purge', 'CAT:RFU', 'temp-rfu', 'CAT:RFU');
addLink('p-tb', 'http://en.wikipedia.org/enwiki/w/index.php?title=Wikipedia:Administrators%27_noticeboard&action=purge', 'WP:AN', 'temp-an', 'WP:AN');
addLink('p-tb', 'http://en.wikipedia.org/enwiki/w/index.php?title=Special%3ALog&type=newusers&user=&page=', 'New Users', 'temp-newuser', 'New Users');
addLink('p-tb', 'http://en.wikipedia.org/enwiki/w/index.php?title=Special:Contributions&limit=30&target=newbies', 'Newbie Contribs', 'temp-newbcont', 'Newbie Contribs');
addLink('p-tb', 'http://en.wikipedia.org/enwiki/w/index.php?title=Special:Recentchanges&limit=30&hideliu=1', 'IP Contribs', 'temp-ipcont', 'IP Contribs');
addLink('p-tb', 'http://en.wikipedia.org/enwiki/w/index.php?title=Special:Uncategorizedimages&limit=500&offset=0', 'Uncat Images', 'temp-uncatim', 'Uncat images');
}

addOnloadHook(ReplaceDeletedTemplate_onload);

importScript('User:Lupin/popups.js');
importScript("User:Lupin/recent2.js");

/**** quick image delete ****/
if (1 == 0)
document.write('<script type="text/javascript"' +
  'src="http://en.wikipedia.org/enwiki/w/index.php?title=User:Howcheng/quickimgdelete.js' +
  '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

/* This is to keep track of who is using this extension: [[User:Howcheng/quickimgdelete.js]] */

importScript('User:AzaToth/morebits.js');
//importScript('User:AzaToth/twinklefluff.js');
importScript('User:B/oldfluff.js');
/*importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu');
importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css');*/
importScript('User:AzaToth/twinklewarn.js');
importScript('User:AzaToth/twinklespeedy.js');
importScript('User:AzaToth/twinklediff.js');
importScript('User:AzaToth/twinkleprotect.js');
importScript('User:AzaToth/twinkleprod.js');
importScript('User:AzaToth/twinkleimage.js');
importScript('User:AzaToth/twinklexfd.js');
importScript('User:AzaToth/salt.js');
TwinkleConfig = {
 	userTalkPageMode	:	'tab', //'window', 'tab' or 'blank'
 	showSharedIPNotice	:	true, // true or false
 	openAOLAnonTalkPage	:	false, // true or false
 	addAdToSummary		:	false, // true or false
 	addAdToDeletionSummary	:	false, // true or false (admin only)
 	watchSpeedyPages	:	[ 'g3', 'g5', 'g10', 'g11', 'g12' ], // CSD normals
 	watchRevertedPages	:	[ 'agf', 'norm', 'vand' ], // agf, norm or vand
        deletionSummaryAd       :       '',
        markWarningsAsMinor     :       false
 };

/*</pre>*/

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/enwiki/w/index.php?title=User:Voice_of_All/Sleeper/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

// History tools
mw.loader.load(
             'https://en.wikipedia.org/enwiki/w/index.php?title=User:Voice_of_All/History/monobook.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');

//

// [[User:Krimpet/CH2.js]]
importScript('User:Krimpet/CH2.js');
addOnloadHook(function () {
    var x;
    if (!(x = document.getElementById('ca-edit') )) return;
    var url;
    if (!(url = x.getElementsByTagName('a')[0] )) return;
    if (!(url = url.href )) return;
    var y = mw.util.addPortletLink('p-cactions', url+"&section=0", '0', 'ca-edit-0',
                           'Edit the lead section of this page', '0', x.nextSibling);

    y.className = x.className;  // steal classes from the the edit tab...
    x.className = 'istalk';     // ...and make the edit tab have no right margin

    // exception: don't steal the "selected" class unless actually editing section 0:
    if (/(^| )selected( |$)/.test(y.className)) {
        if (!document.editform || !document.editform.wpSection
            || document.editform.wpSection.value != "0") {
            y.className = y.className.replace(/(^| )selected( |$)/g, "$1");
            x.className += ' selected';
        }
    }
});

//