User:Equazcion/WatchStyleT.js

if (wgPageName == "Special:Watchlist") {

if (typeof mbTooltip != "undefined") var newsMb = true; if (typeof adminRights == "undefined") var adminRights = false;

$('strong.mw-watched').parents('table').addClass('mw-watched');

var newsIntCode = ' ' + ' New changes style: ' + ' Subtle ' + ' Italics ' + ' Bold ' + ' Stars ' + ' Stars + Bold ' + ' Fade old ' + ' Color change ' + ' Disable ';

$('[value="Go"]:submit').after(newsIntCode); $('.newsLabel').css('padding-right', '5px').css('padding-left', '3px');

$('[name="newsStyle"]:radio').click(function{ newsStyleChange($(this).attr('value')); });

function newsStyleChange(newsChoice) { // Restore existing $('strong.mw-watched').css('border-bottom', 'none').css('font-style','normal'); $('strong.mw-watched').find('a').css('font-weight', 'normal').css('padding-left','0').css('background','none'); $('table.mw-enhanced-rc').find('td').css('opacity', '1').css('font-style','normal').css('font-size','100%'); $('table.mw-enhanced-rc').find('a').css('opacity', '1').css('font-style','normal').css('font-size','100%').css('color', '').css('font-weight', 'normal');

// Apply choice if (newsChoice == 1) $('strong.mw-watched').css('border-bottom', '1px dotted #000'); if (newsChoice == 2) $('strong.mw-watched').css('font-style', 'italic'); if (newsChoice == 3) $('strong.mw-watched').find('a').css('font-weight', 'bold'); if (newsChoice == 4) $('strong.mw-watched').find('a').css('padding-left','16px').css('background', 'url(//upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Pentagram_dis.svg/13px-Pentagram_dis.svg.png) no-repeat left');

if (newsChoice == 5) { $('strong.mw-watched').find('a').css('font-weight', 'bold'); $('strong.mw-watched').find('a').css('padding-left','16px').css('background', 'url(//upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Pentagram_dis.svg/13px-Pentagram_dis.svg.png) no-repeat left'); }

if (newsChoice == 6) { $('table.mw-enhanced-rc').find('td:gt(0)').css('opacity', '0.8'); $('table.mw-enhanced-rc').find('a:first').css('opacity', '0.68').css('font-style','italic').css('font-size','98%'); $('table.mw-watched').find('a:first').css('opacity', '1').css('font-style','normal').css('font-size','100%'); $('table.mw-watched').find('td:gt(0)').css('opacity', '1').css('font-style','normal').css('font-size','100%'); }

if (newsChoice == 7) $('strong.mw-watched').find('a').css('color', '#008B8B'); if (newsChoice == 8) $('strong.mw-watched').find('a').css('font-weight', 'normal');

// Store setting localStorage.setItem('newsStore', newsChoice);

if (newMb == true) markBlocked; if (adminRights == true) adminRightsRun;

}

var newsOption = localStorage.getItem('newsStore'); $('[name="newsStyle"][value="' + newsOption + '"]').click;

}

// Begin MarkBlocked function markBlocked( container ) { var contentLinks = container ? $(container).find('a') : mw.util.$content.find('a').add('#ca-nstab-user a') mw.util.addCSS('\ .user-blocked-temp{'  + (window.mbTempStyle||'opacity: 0.7; text-decoration: line-through') + '}\ .user-blocked-indef{'  + (window.mbIndefStyle||'opacity: 0.4; font-style: italic; text-decoration: line-through') + '}\ .user-blocked-tipbox{' + (window.mbTipBoxStyle||'font-size:smaller; background:#FFFFF0; border:1px solid #FEA; padding:0 0.3em; color:#AAA') + '}\ ') var mbTooltip = window.mbTooltip || '; blocked ($1) by $2: $3 ($4 ago)' //get local alias for "Contributions" from "my contribs" link on top var mwCont = /:([^\/]+)\//.exec( $('#pt-mycontris').find('a').attr('href') ) if( mwCont ) mwCont = mwCont[1]; else mwCont = window.mbLocalContribsName || 'Contributions' //RegExp for all links thast are  User:| User_talk: |  Special:Contributions/ (localized) | Special:Contributions/ (for userscripts) var userTitleRX = new RegExp('^' + '(' + wgFormattedNamespaces[2] + ':' + '|' + wgFormattedNamespaces[3] + ':' + '|' + wgFormattedNamespaces[-1] + ':' + mwCont + '\\/' + '|' + 'Special:Contributions\\/' + ')' + '([^\\/#]+)$') //RegExp for links var articleRX = new RegExp( '^' + wgArticlePath.replace('$1', '') + '([^#]+)' ) var scriptRX = new RegExp( '^' + wgScript + '\\?title=([^#&]+)' ) var userLinks = {} var url, ma, pgTitle //find all "user" links and save them in userLinks : { 'users': [, , ...], 'user2': [ , , ...], ... } contentLinks.each(function(i, lnk){  url = $(lnk).attr('href')   if( !url || url.charAt(0) != '/' ) return   else if( ma = articleRX.exec(url) ) pgTitle = ma[1]   else if( ma =  scriptRX.exec(url) ) pgTitle = ma[1]   else return   pgTitle = decodeURIComponent(pgTitle).replace(/_/g, ' ')   user = userTitleRX.exec(pgTitle)   if( !user ) return   user = user[2]   $(lnk).addClass('userlink')   if ( !userLinks[user] ) userLinks[user] = []   userLinks[user].push(lnk) }) //convert users into array var users = [] for (var u in userLinks) users.push(u) if( users.length == 0 ) return //API request var wgServerTime, apiRequests = 0 var waitingCSS = mw.util.addCSS('a.userlink {opacity:' + (window.mbLoadingOpacity||0.85) + '}') while( users.length > 0 ){ apiRequests++ $.getJSON(   mw.util.wikiScript('api') + '?format=json&action=query',    { list: 'blocks', bklimit: 100, bkusers: users.splice(0,50).join('|'),      bkprop: 'user|by|timestamp|expiry|reason' }, //no need for 'id|flags'    markLinks  ) } return //the end //callback: receive data and mark links function markLinks(resp, status, xhr){ wgServerTime = new Date( xhr.getResponseHeader('Date') ) var list, blk, tip, links, lnk if( !resp || !(list=resp.query) || !(list=list.blocks) ) return for( var i=0; i<list.length; i++){ blk = list[i] if( /^in/.test(blk.expiry) ){ clss = 'user-blocked-indef' blTime = blk.expiry }else{ clss = 'user-blocked-temp' blTime = inHours ( parseTS(blk.expiry) - parseTS(blk.timestamp) ) }   tip = mbTooltip.replace('$1', blTime).replace('$2', blk.by).replace('$3', blk.reason) .replace('$4', inHours ( wgServerTime - parseTS(blk.timestamp) ) ) links = userLinks[blk.user] for (var k=0; k date function parseTS(ts){ var m = ts.replace(/\D/g,'').match(/(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/) return new Date ( Date.UTC(m[1], m[2]-1, m[3], m[4], m[5], m[6]) ) } function inHours(ms){ //milliseconds -> "2:30" or 5,06d or 21d var mm = Math.floor(ms/60000) if( !mm ) return Math.floor(ms/1000)+'s' var hh = Math.floor(mm/60); mm = mm % 60 var dd = Math.floor(hh/24); hh = hh % 24 if (dd) return dd + (dd<10?'.'+zz(hh):'') + 'd' else return hh + ':' + zz(mm) } function zz(v){ // 6 -> '06' if( v <= 9 ) v = '0' + v return v } } // End MarkBlocked

// Begin AdminRights -- function adminRightsRun{ $.getJSON( mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:Amalthea_(bot)/userhighlighter.js/sysop.js', function(data){		$(function{ function highlightadmins_inner(n,h) //node, relevant hyperlink fragment {			 if (n.nodeType!=1||n.tagName.toLowerCase!="a") return 0; // not an anchor if (n.href.indexOf(wgScript+"?title="+h) == -1 &&			     n.href.indexOf(wgArticlePath.split("$1")[0]+h) == -1) return 0; // to the wrong target var u=n.href.split(h)[1]; if(data[u.split("_").join(" ")]==1) {			   n.style.backgroundColor="#00FFFF"; if(n.className==null||n.className=="") n.className="amalthea_userhighlighter_sysop"; else n.className+=" amalthea_userhighlighter_sysop"; }			 return 1; }			function highlightadmins(n) //node {			 while(n!=null) {			   if(highlightadmins_inner(n,"User:")) n=n.nextSibling; else if(highlightadmins_inner(n,"User_talk:")) n=n.nextSibling; else if(highlightadmins_inner(n,"Special:Contributions:")) n=n.nextSibling; else {			     if(n.firstChild!=null) highlightadmins(n.firstChild); n=n.nextSibling; }			 }			}			highlightadmins(document.getElementById('bodyContent')); });		}); } //End AdminRights -