diff options
Diffstat (limited to 'notifier/subject_hatelabo_bottle.js')
-rw-r--r-- | notifier/subject_hatelabo_bottle.js | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/notifier/subject_hatelabo_bottle.js b/notifier/subject_hatelabo_bottle.js index 2335cad..71a5a27 100644 --- a/notifier/subject_hatelabo_bottle.js +++ b/notifier/subject_hatelabo_bottle.js @@ -1,7 +1,7 @@ // PLUGIN_INFO//{{{ var PLUGIN_INFO = <VimperatorPlugin> - <name>{name}</name> + <name>{NAME}</name> <description>notifies if hatena bottle was changed.</description> <description lang="ja">はてなボトルの変更通知。</description> <author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author> @@ -32,18 +32,21 @@ notifier.subject.register(notifier.SubjectHttp, { logger.log('preInitialize: '); }, parse: function(res) { - // if (this.count == 0) return []; for debug - if (!res.isSuccess() || res.responseText == '') return null; - return res.getHTMLDocument('id("body")//div[contains(concat(" ", @class, " "), " entry ")]'); + // if (this.count == 0) return []; // for debug + var doc = res.getHTMLDocument('id("body")//div[contains(concat(" ", @class, " "), " entry ")]'); + return doc; }, diff: function(cache, parsed) parsed.filter(function(element) !cache.some(function(c) c.textContent == element.textContent)), - buildMessages: function(diff) - diff.map(function(d) - new notifier.Message('Hatelab bottle', $U.xmlSerialize(d), { - growl: { life: 7000 } - })) + buildMessages: function(diff) { + return diff.map($U.bind(this, function(d) { + var permalink = $U.getNodesFromXPath('descendant::a[@class="hatena-star-uri"]', d); + if (permalink.length > 0) + permalink = URL + permalink[0]; + return new notifier.Message('Hatelab bottle', $U.xmlSerialize(d), permalink) + })); + } }); })(); |