User:Elahrairah/vector.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. |
![]() | The accompanying .css page for this skin is at User:Elahrairah/vector.css. |
importScript('User:Dr_pda/prosesize.js'); //[[User:Dr_pda/prosesize.js]]
importScript('User:Ucucha/duplinks.js');
importScript('User:ais523/adminrights.js'); // User:ais523/adminrights.js
addOnloadHook(function () {
var rights_isAdmin = (wgUserGroups.toString().indexOf('sysop') != -1);
if (!rights_isAdmin)
return; //Restrict to admins.
if (wgNamespaceNumber != "2" && wgNamespaceNumber != "3")
return; // restrict to User and User talk
var title = wgTitle;
addPortletLink('p-tb', '/wiki/Special:Userrights/'+title,
'User rights', 't-userrights', 'User rights for "'+title+'"');
});
if (typeof(unsafeWindow) != 'undefined')
{
var console = unsafeWindow.console;
importStylesheet = unsafeWindow.importStylesheet;
mw = unsafeWindow.mw;
sajax_init_object = unsafeWindow.sajax_init_object;
}
function markEditsAfterMyOwn()
{
if (!mw.config.get('wgPageName').match('Special:Contributions')) return;
importStylesheet('User:Gary King/highlighted link.css');
if ($('#contentSub').children().eq(0).text() == mw.config.get('wgUserName')) var isOwnUserContributions = true;
else var isOwnUserContributions = false;
// get watchlist items first so that they aren't marked as well, only for current user's contributions
if (isOwnUserContributions)
$.get(mw.config.get('wgScriptPath') + '/api.php', { action: 'query', list: 'watchlist', wllimit: 500, format: 'json' }, markEditsAfterMyOwnWatchlist);
else markEditsAfterMyOwnMark('', false);
};
function markEditsAfterMyOwnWatchlist(obj)
{
var watchlist = obj['query']['watchlist'];
var pagesToIgnore = {};
for (var i = 0; i < watchlist.length; i++)
{
if (pagesToIgnore[watchlist[i]['title']]) pagesToIgnore[watchlist[i]['title']]++;
else pagesToIgnore[watchlist[i]['title']] = 1;
}
markEditsAfterMyOwnMark(pagesToIgnore, true);
}
function markEditsAfterMyOwnMark(pagesToIgnore, isOwnUserContributions)
{
if (isOwnUserContributions && $.isEmptyObject(pagesToIgnore)) $('#contentSub').append('. <span class="no-items-on-watchlist" style="color: #000; font-weight: bold;">Your watchlist is empty.</span>');
if (!pagesToIgnore) pagesToIgnore = {};
var markedPages = {};
$('#bodyContent ul:last').children().each(function()
{
var edit = $(this);
if (edit[0].nodeType == 3) return true;
var pageName = edit.children().eq(0).attr('title');
if ($('.mw-uctop', edit).length) markedPages[pageName] = 1;
else
{
if (markedPages[pageName]) markedPages[pageName]++;
else
{
// get the link to highlight it
var nodeNumber;
var children = edit.children();
// in most cases
if (children.eq(3).length && children.eq(3)[0].nodeName == 'A') nodeNumber = 3;
// is a minor edit
else if (children.eq(4).length && children.eq(4)[0].nodeName == 'A') nodeNumber = 4;
// a deleted edit
else if (children.eq(2).length && children.eq(2)[0].nodeName == 'A') nodeNumber = 2;
if (nodeNumber)
{
children.eq(nodeNumber).addClass(pagesToIgnore[pageName] ? 'highlighted-link-watched' : 'highlighted-link');
markedPages[pageName] = 1;
}
}
}
});
}
$(markEditsAfterMyOwn);