From 882354c8d5c3de1e79391e3deb9d182c9600e135 Mon Sep 17 00:00:00 2001
From: teramako
Date: Sat, 3 Jan 2009 03:36:07 +0000
Subject: first release
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27811 d0d07461-0603-4401-acd4-de1884942a52
---
notifier/subject_hatena_message.js | 58 ++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 notifier/subject_hatena_message.js
(limited to 'notifier')
diff --git a/notifier/subject_hatena_message.js b/notifier/subject_hatena_message.js
new file mode 100644
index 0000000..d14878a
--- /dev/null
+++ b/notifier/subject_hatena_message.js
@@ -0,0 +1,58 @@
+var PLUGIN_INFO =
+
+ {NAME}
+ hatena message notifier
+ はてなメッセージの変更通知。
+ teramako
+ 0.1
+ MPL 1.1/GPL 2.0/LGPL 2.1
+ 2.0pre
+ 2.0pre
+ http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier/subject_hatena_message.js
+;
+//}}}
+(function() {
+
+var notifier = liberator.plugins.notifier;
+if (!notifier) return;
+
+var libly = notifier.libly;
+var $U = libly.$U;
+var logger = $U.getLogger('subject_hatena_message');
+
+var URL = 'http://m.hatena.ne.jp';
+
+notifier.subject.register(notifier.SubjectHttp, {
+ interval: 60,
+ options: {
+ url: URL,
+ headers: null,
+ extra: {}
+ },
+ preInitialize: function() {
+ [username, password] = $U.getUserAndPassword('https://www.hatena.ne.jp', 'https://www.hatena.ne.jp');
+ this.options.extra.username = username;
+ this.options.extra.password = password;
+ return (username && password) ? true : false;
+ },
+ parse: function(res) {
+ var doc = res.getHTMLDocument('//table[@class="list"]//tr');
+ return doc;
+ },
+ diff: function(cache, parsed)
+ parsed.filter(function(element)
+ !cache.some(function(c) c.textContent == element.textContent)),
+ buildMessages: function(diff) {
+ return diff.map($U.bind(this, function(d) {
+ var anchor = $U.getFirstNodeFromXPath('descendant::a[@class="message-title"]', d);
+ var permalink = URL + (anchor.href ? anchor.href : "");
+ var [title, message, date] = [elm.textContent.replace(/^\s+|\s+$/g,"").replace(/>\s+<") for ([i,elm] in Iterator(d.cells))];
+ var html = title + ' (' + date + ')
' + message;
+ return new notifier.Message('Hatena::Message', html, permalink)
+ }));
+ }
+});
+
+})();
+// vim: set fdm=marker sw=4 ts=4 sts=0 et:
+
--
cgit v1.2.3