LDR - Emphasize Authors

By iwamot Last update May 15, 2008 — Installed 27 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
// ==UserScript==
// @name           LDR - Emphasize Authors
// @namespace      http://iwamot.com/
// @include        http://reader.livedoor.com/reader/*
// ==/UserScript==

// case sensitive
var target_authors = [
	'hogehoge',
	'fugafuga'
];

GM_addStyle(<><![CDATA[
	.LDREA_item h2 a {
		color: #fc8181 !important;
	}

	.LDREA_author {
		color: #fc8181 !important;
		font-weight: bold !important;
	}
]]></>);

(function() {
	var w = unsafeWindow || window;
	var _onload = w.onload;
	w.onload = function () {
		_onload();
		main();
	}

	function main() {with (w) {
		register_hook('after_printfeed', function(feed) {
			feed.items.forEach(function(item) {
				if (!item.author) {
					return;
				}

				var emphasize = target_authors.some(function(author) {
					return (author == item.author);
				});
				if (!emphasize) {
					return;
				}

				(function(div_id) {
					try {
						addClass(div_id, 'LDREA_item');
						$(div_id).innerHTML = $(div_id).innerHTML.replace(
							/class="author"/, 'class="author LDREA_author"'
						);
					} catch (e) {
						var self = arguments.callee;
						setTimeout(function() {self(div_id);}, 500);
					}
				})('item_' + item.id);
			});
		});
	}}
})();