Greasemonkeyの 「mixi 共通コミュをハイライト」 スクリプトを拡張してみた

t.p.fields さんのところで公開されている HighLightMixiCommonCommunities をメンバーの参加コミュ一覧ページにも反応するように拡張してみた(コピペで!)
http://tpfields.xrea.jp/javascript/hilight-mixi-common-communities.html

要はこのページ↓でも色が変わるようになります。
http://mixi.jp/related_community.pl?id=192417

パッチは以下の通り。ver 0.4.1f に対するパッチです。

--- highlightmixicommoncommu.user.js.o	Sat Feb 14 18:31:36 2009
+++ highlightmixicommoncommu.user.js	Sun May 17 11:21:04 2009
@@ -69,17 +69,22 @@
 	}
 }
 
+function getMyComs() {
+	var com = GM_getValue('communities', '').split(',');
+	var myCom = {};
+	for (var i = 0; i < com.length; i++)
+		if (com[i])
+			myCom[com[i]] = true;
+	return myCom;
+}
+
 function highlight(){
 
 	//通常画面ハイライト
 	if (document.location.href.match(/show_friend\.pl\?.*id=(\d+)/))
 	{
 		// コミュニティ一覧画面
-		var com = GM_getValue('communities', '').split(',');
-		var myCom = {};
-		for (var i = 0; i < com.length; i++)
-			if (com[i])
-				myCom[com[i]] = true;
+		var myCom = getMyComs();
 
 		var comLinks = document.evaluate('//a[starts-with(@href, "view_community.pl")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
 		// 他人のコミュ一覧
@@ -98,11 +103,7 @@
 	if (document.location.href.match(/list_community\.pl\?.*id=(\d+)/))
 	{
 		// コミュニティ一覧画面
-		var com = GM_getValue('communities', '').split(',');
-		var myCom = {};
-		for (var i = 0; i < com.length; i++)
-			if (com[i])
-				myCom[com[i]] = true;
+		var myCom = getMyComs();
 
 		var comLinks = document.evaluate('//a[starts-with(@href, "view_community.pl")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
 		if (document.evaluate('//a[@href="manage_community.pl"]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength)
@@ -136,6 +137,23 @@
 					comLink.parentNode.removeAttribute('background');
 					comLink.parentNode.parentNode.style.backgroundColor = '#FCC';
 				}
+			}
+		}
+	}
+
+	// メンバー参加コミュ一覧画面
+	if (document.location.href.match(/related_community\.pl\?.*id=(\d+)/)) {
+		// 自分のコミュIDのハッシュを取得
+		var myCom = getMyComs();
+
+		var comLinks = document.evaluate('//a[starts-with(@href, "related_community.pl")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+		for (var i = 0; i < comLinks.snapshotLength; i++)
+		{
+			var comLink = comLinks.snapshotItem(i);
+			if (myCom[comLink.href.match(/\d+/)])
+			{
+				comLink.parentNode.removeAttribute('background');
+				comLink.parentNode.style.backgroundColor = '#FCC';
 			}
 		}
 	}