Jump to content

User:Technical 13/SandBox/Notification colorizer.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* Colors found so far to represent certain things.
No notifications = "#D2D2D2";// (current gray value)
Thanked = "#14B18A";// (green value from icon)
Reverted = "#575757";// (best average of gray color from icon)
Mentioned = "#3867B1";// (blue value from icon)
Talk page post = "#F9C557";// (old orange color)
Userrights = "#060606";// (Black color from the W icon)
Linked = "#3967B0";// (blue value from icon)
Page reviewed = "#26AA64";// (green value from icon)
Notifications = "#CC0000";// (current red value)
*/
/* NOTE THAT THIS SCRIPT WILL ALWAYS TURN THE ICON GRAY FOR NOW */
/* THIS IS BECAUSE $('li.mw-echo-unread') doesn't exist on the page until you click the notification icon. */
/* I think I can get the information from the API, but I have no time for something that in depth right now. */

var color = "#D2D2D2";
$('li.mw-echo-unread').each(function(){
	/* Thank */// You were thanked [[Special:Log]]
	if($(this).attr('data-notification-category') === "edit-thank" && $(this).attr('data-notification-type') === "edit-thank"){color = "#14B18A";}
	/* Talk */// Someone left a message on your talk page
	if($(this).attr('data-notification-category') === "edit-user-talk" && $(this).attr('data-notification-type') === "edit-user-talk"){color = "#F9C557";}
	/* Reverted */// An edit of yours was reverted
	if($(this).attr('data-notification-category') === "reverted" && $(this).attr('data-notification-type') === "reverted"){color = "#575757";}
	/* Mention */// You were mentioned on a talk page in a discussion
	if($(this).attr('data-notification-category') === "mention" && $(this).attr('data-notification-type') === "mention"){color = "#3867B1";}
	/* Userrights */// Your userrights have changed
	if($(this).attr('data-notification-category') === "system" && $(this).attr('data-notification-type') === "userrights"){color = "#060606";}
	/* Reviewed */// A page you created as been "patrolled"
	if($(this).attr('data-notification-category') === "page-review" && $(this).attr('data-notification-type') === "pagetriage-mark-as-reviewed"){color = "#26AA64";}
	/* Linked */// An article you have created has been linked from another article
	if($(this).attr('data-notification-category') === "article-linked" && $(this).attr('data-notification-type') === "page-linked"){color = "#3967B0";}
});
if($('a.mw-echo-notifications-badge').html() === "1"){
	$('a.mw-echo-notifications-badge').css('background-color', color);
}