svnno****@sourc*****
svnno****@sourc*****
2007年 10月 19日 (金) 23:03:47 JST
Revision: 227 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=bbs2ch&view=rev&rev=227 Author: flyson Date: 2007-10-19 23:03:47 +0900 (Fri, 19 Oct 2007) Log Message: ----------- 内容テキストの取得をXPathの代わりにtextContentを使うようにした。 Modified Paths: -------------- trunk/bbs2chreader/chrome/content/bbs2chreader/post/filter.js -------------- next part -------------- Modified: trunk/bbs2chreader/chrome/content/bbs2chreader/post/filter.js =================================================================== --- trunk/bbs2chreader/chrome/content/bbs2chreader/post/filter.js 2007-10-18 14:41:54 UTC (rev 226) +++ trunk/bbs2chreader/chrome/content/bbs2chreader/post/filter.js 2007-10-19 14:03:47 UTC (rev 227) @@ -61,11 +61,11 @@ doc.normalize(); var filter = {}; - filter.title = this._getNodeText(doc, "postFilter/title/text()"); + filter.title = this._getTextContent(doc, "title"); if(!filter.title) filter.title = aLocalFile.leafName.replace(/\.xml$/, ""); - filter.description = this._getNodeText(doc, "postFilter/description/text()"); - filter.version = this._getNodeText(doc, "postFilter/version/text()"); - filter.script = this._getNodeText(doc, "postFilter/script/text()"); + filter.description = this._getTextContent(doc, "description"); + filter.version = this._getTextContent(doc, "version"); + filter.script = this._getTextContent(doc, "script"); filter.scriptFile = aLocalFile; filter.scriptDoc = doc; if(!filter.script) return null; @@ -73,15 +73,10 @@ return filter; }, - _getNodeText: function(aDoc, aXpath){ - var result = new Array(); - var xpathResult = aDoc.evaluate(aXpath, aDoc, null, - XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - for(let i=0; i<xpathResult.snapshotLength; i++){ - var node = xpathResult.snapshotItem(i); - result.push(node.nodeValue); - } - return result.join(""); + _getTextContent: function(aDoc, aTagName){ + var nodes = aDoc.getElementsByTagName(aTagName); + if(nodes.length>0) return nodes[0].textContent; + return null; }, execFilterScript: function(aPostFilter, aTextArea){