From 0c06e6b688efaa14c360edcc4f30bfd54a0afcc1 Mon Sep 17 00:00:00 2001 From: anekos Date: Sat, 3 Apr 2010 11:30:34 +0000 Subject: pageinfo 修正 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37145 d0d07461-0603-4401-acd4-de1884942a52 --- stella.js | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'stella.js') diff --git a/stella.js b/stella.js index 21bf2f6..2964585 100644 --- a/stella.js +++ b/stella.js @@ -39,7 +39,7 @@ let PLUGIN_INFO = すてら For Niconico/YouTube/Vimeo, Add control commands and information display(on status line). ニコニコ動画/YouTube/Vimeo 用。操作コマンドと情報表示(ステータスライン上に)追加します。 - 0.26.2 + 0.26.3 anekos new BSD License (Please read the source code comments of this plugin) 修正BSDライセンス (ソースコードのコメントを参照してください) @@ -475,7 +475,32 @@ Thanks: toTimeCode: function (v) (U.isNum(v) ? (parseInt((v / 60)) + ':' + U.lz(v % 60, 2)) - : '??:??') + : '??:??'), + + toXML: function (html) { + function createHTMLDocument (source) { + let wcnt = window.content; + let doc = wcnt.document.implementation.createDocument( + 'http://www.w3.org/1999/xhtml', + 'html', + wcnt.document.implementation.createDocumentType( + 'html', + '-//W3C//DTD HTML 4.01//EN', + 'http://www.w3.org/TR/html4/strict.dtd' + ) + ); + let range = wcnt.document.createRange(); + range.selectNodeContents(wcnt.document.documentElement); + let content = doc.adoptNode(range.createContextualFragment(source)); + doc.documentElement.appendChild(content); + return doc; + } + + function replaceHTML (s) + s.replace(/
/g, '
').replace(/ /g, ' '); + + return replaceHTML(createHTMLDocument(html).documentElement.innerHTML); + } }; @@ -881,11 +906,8 @@ Thanks: set muted (value) ((value ? this.player.mute() : this.player.unMute()), value), get pageinfo () [ - [ - name, - U.xpathGet(this.xpath[name]).innerHTML.replace(/ /g, ', ') - ] - for (name in this.xpath) + ['comment', U.toXML(U.xpathGet(this.xpath.comment).innerHTML)], + ['tags', U.toXML(U.xpathGet(this.xpath.tags).innerHTML)] ], get player () @@ -1060,13 +1082,13 @@ Thanks: let v = content.wrappedJSObject.Video; return [ ['thumbnail', ], - ['comment', v.description], + ['comment', U.toXML(v.description)], [ 'tag', [ {t} for each (t in Array.slice(v.tags)) - ].join() + ].join(' ') ] ]; }, -- cgit v1.2.3