Color code StackOverflow users by recent activity/last login

Color highlight users by recent activity

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Color code StackOverflow users by recent activity/last login
// @namespace    http://your.homepage/
// @version      0.1
// @description  Color highlight users by recent activity
// @author       You
// @match        http://*.stackexchange.com/users*
// @grant        none
// ==/UserScript==
(function () {
	function daycol(n, html) { //wicked, 2 functions in one, based on second param
		var el = document.createElement('p');
		if (html) return ~~((new Date() - new Date((el.innerHTML = html, el).querySelector(n + ' .relativetime').title)) / 864e5);
		return n < 60 ? 'limegreen' : n < 180 ? 'goldenrod' : n < 365 ? 'firebrick' : 'black';
	}
	[].forEach.call(document.querySelectorAll('.user-info'), function (user) {
		$.get(user.querySelector('a').href, function (profile) {
			$.get(user.querySelector('a').href + '?tab=answers&sort=newest', function (answers) {
				var login = daycol('.icon-time +', profile),
					answer = daycol('#user-tab-answers', answers);
				user.querySelector('.user-tags').innerHTML = '<b style=padding:5px;background:' + daycol(login) + '>Days Since Login ' + login + '  Answer ' + answer + '</b>';
				user.style.cssText = 'color:#fff;width:21em;margin:1px;background:' + daycol(answer);
			});
		});
	});
}());