diff options
author | suVene | 2008-12-19 18:24:47 +0000 |
---|---|---|
committer | suVene | 2008-12-19 18:24:47 +0000 |
commit | 516b13e4a197ac9c98d35b0e558c281dbd099140 (patch) | |
tree | 819f165c47e824db098b1a3c614333032bcf0e40 | |
parent | 5749c57ec0f8341254fe2baaf5342e6d2bb0a73c (diff) | |
download | vimperator-plugins-516b13e4a197ac9c98d35b0e558c281dbd099140.tar.bz2 |
* get absolute path of <a>, <img>.
* mod $U.pathToURL
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/branches/1.2@27108 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | multi_requester.js | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/multi_requester.js b/multi_requester.js index 62705c9..239094f 100644 --- a/multi_requester.js +++ b/multi_requester.js @@ -5,12 +5,12 @@ var PLUGIN_INFO = <description>request, and the result is displayed to the buffer.</description> <description lang="ja">リクエストの結果をバッファに出力する。</description> <author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author> - <version>0.4.4</version> + <version>0.4.6</version> <minVersion>1.2</minVersion> <maxVersion>1.2</maxVersion> <detail><![CDATA[ == Needs Library == -- _libly.js(ver.0.1.4) +- _libly.js(ver.0.1.11) @see http://coderepos.org/share/browser/lang/javascript/vimperator-plugins/trunk/_libly.js == Usage == @@ -345,7 +345,7 @@ var MultiRequester = { var el = res.getHTMLDocument(extractLink); if (!el) throw 'extract link failed.: extractLink -> ' + extractLink; - var url = $U.pathToURL(el[0]); + var url = $U.pathToURL(el[0], res.req.url); var req = new libly.Request(url, null, $U.extend(res.req.options, {extractLink: true})); req.addEventListener('onException', $U.bind(this, this.onException)); req.addEventListener('onSuccess', $U.bind(this, this.onSuccess)); @@ -368,7 +368,7 @@ var MultiRequester = { MultiRequester.doProcess = false; } - var url, escapedUrl, xpath, doc, html, extractLink; + var url, escapedUrl, xpath, doc, html, extractLink, ignoreTags; try { @@ -383,11 +383,23 @@ var MultiRequester = { this.extractLink(res, extractLink); return; } - var ignoreTags = ['script'].concat(libly.$U.A(res.req.options.siteinfo.ignoreTags)); + ignoreTags = ['script'].concat(libly.$U.A(res.req.options.siteinfo.ignoreTags)); doc = document.createElementNS(null, 'div'); - res.getHTMLDocument(xpath, null, ignoreTags, function(node, i) { doc.appendChild(node) } ); + res.getHTMLDocument(xpath, null, ignoreTags, function(node, i) { + if (node.tagName.toLowerCase() != 'html') + doc.appendChild(node); + }); if (!doc) throw 'XPath result is undefined or null.: XPath -> ' + xpath; + $U.getNodesFromXPath('descendant-or-self::a | descendant-or-self::img', doc, function(node) { + var tagName = node.tagName.toLowerCase(); + if (tagName == 'a') { + node.href = $U.pathToURL(node, url, res.doc); + } else if (tagName == 'img') { + node.src = $U.pathToURL(node, url, res.doc); + } + }); + html = '<a href="' + escapedUrl + '" class="hl-Title" target="_self">' + escapedUrl + '</a>' + $U.xmlSerialize(doc); |