aboutsummaryrefslogtreecommitdiffstats
path: root/notifier
diff options
context:
space:
mode:
authorteramako2009-01-03 03:36:07 +0000
committerteramako2009-01-03 03:36:07 +0000
commit882354c8d5c3de1e79391e3deb9d182c9600e135 (patch)
tree6a224d4d9fe3419ca35d102cf6ed7a303d8d16bf /notifier
parentfd596c870dbacce1f31bcf5cd58281931744c4a8 (diff)
downloadvimperator-plugins-882354c8d5c3de1e79391e3deb9d182c9600e135.tar.bz2
first release
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27811 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'notifier')
-rw-r--r--notifier/subject_hatena_message.js58
1 files changed, 58 insertions, 0 deletions
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 =
+<VimperatorPlugin>
+ <name>{NAME}</name>
+ <description>hatena message notifier</description>
+ <description lang="ja">はてなメッセージの変更通知。</description>
+ <author mail="teramako@gmail.com" homepage="http://vimperator.g.hatena.ne.jp/teramako/">teramako</author>
+ <version>0.1</version>
+ <license>MPL 1.1/GPL 2.0/LGPL 2.1</license>
+ <minVersion>2.0pre</minVersion>
+ <maxVersion>2.0pre</maxVersion>
+ <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier/subject_hatena_message.js</updateURL>
+</VimperatorPlugin>;
+//}}}
+(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+</g,"><") for ([i,elm] in Iterator(d.cells))];
+ var html = title + ' (' + date + ')<br/>' + message;
+ return new notifier.Message('Hatena::Message', html, permalink)
+ }));
+ }
+});
+
+})();
+// vim: set fdm=marker sw=4 ts=4 sts=0 et:
+