ヨーキョクデイ

いろいろ雑食

Foxage2ch 改造

スレッド情報の mozStorage 化 ということで、bbs2chreader でスレッド情報の取得方法が変わり、従来よりも楽になった。これに伴って Foxage2ch の bbs2chreader との連携強化についての改造箇所も減った。Foxage2ch 2.6.2 でテスト。

--- foxage2ch.js.orig	2007-12-22 01:41:20.000000000 +0900
+++ foxage2ch.js	2008-01-23 00:34:22.000000000 +0900
@@ -581,19 +581,40 @@
 		while (resEnum.hasMoreElements()) {
 			var threadRes = resEnum.getNext().QueryInterface(Ci.nsIRDFResource);
 			var datName = foxage2chUtils.parseToDAT(threadRes.Value);
 			if (datName in aSubject) {
-				var lastNum = parseInt(foxage2chData.getProperty(threadRes, "lastNum") || 0);
+				var lastNum;
+				if ( foxage2ch.prefs.bbs2chreader ) {
+					var b2rStorageService = Cc["@bbs2ch.sourceforge.jp/b2r-storage-service;1"].getService(Ci.b2rIStorageService);
+					var boardURL = Cc['@mozilla.org/network/standard-url;1'].createInstance(Ci.nsIURL);
+					boardURL.spec = foxage2chUtils.parseToURL(aBoardRes);
+					var threadData = b2rStorageService.getThreadData(boardURL, datName);
+					lastNum = threadData ? threadData.lineCount : 0;
+				} else {
+					lastNum = parseInt(foxage2chData.getProperty(threadRes, "lastNum") || 0);
+				}
 				var newNum  = parseInt(aSubject[datName][1]);
 				foxage2chData.setProperty(threadRes, "lastNum", newNum.toString());
 				if (newNum > lastNum) {
 					foxage2chData.setProperty(threadRes, "status", "updated");
 					var title = foxage2chUtils.getRealTitle(foxage2chData.getProperty(threadRes, "title"));
-					var readNum = parseInt(foxage2chData.getProperty(threadRes, "readNum") || 0);
+					var readNum = foxage2ch.prefs.bbs2chreader ? lastNum : parseInt(foxage2chData.getProperty(threadRes, "readNum") || 0);
 					foxage2chData.setProperty(threadRes, "title", "[" + (newNum - readNum) + "] " + title);
 					foxage2chData.moveItem(threadRes, aBoardRes, aBoardRes, 1);
 					hit++;
+					continue;
+				} else if ( foxage2ch.prefs.bbs2chreader &&
+						(lastNum != parseInt(foxage2chData.getProperty(threadRes, "readNum") || 0))) {
+					foxage2chData.setProperty(threadRes, "readNum", lastNum);
+				}
+				if ( foxage2ch.prefs.bbs2chreader &&
+						(lastNum >= parseInt(foxage2chData.getProperty(threadRes, "readNum") || 0)) &&
+						(foxage2chData.getProperty(threadRes, "status") == "updated")) {
+					var title = foxage2chUtils.getRealTitle(foxage2chData.getProperty(threadRes, "title"));
+					foxage2chData.setProperty(threadRes, "status", "");
+					foxage2chData.setProperty(threadRes, "title", title);
 				}
+				foxage2ch.updateThreadCount(aBoardRes);
 			}
 			else {
 				foxage2chData.setProperty(threadRes, "status", "datout");
 			}

こんなんでいいはず。