aboutsummaryrefslogtreecommitdiffstats
path: root/notifier/subject_twitter_scraper.js
diff options
context:
space:
mode:
authorsuVene2008-12-29 15:36:08 +0000
committersuVene2008-12-29 15:36:08 +0000
commit422295f4b044038d04a9a9e7d8b51a2d71292f2e (patch)
treed14b2aac76957ccf36e7f784b1489b0425516ff6 /notifier/subject_twitter_scraper.js
parent83d0b3b6cf9698a5f7615458631ff626bd840966 (diff)
downloadvimperator-plugins-422295f4b044038d04a9a9e7d8b51a2d71292f2e.tar.bz2
add subject_twitter.scraper.js
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27570 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'notifier/subject_twitter_scraper.js')
-rwxr-xr-xnotifier/subject_twitter_scraper.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/notifier/subject_twitter_scraper.js b/notifier/subject_twitter_scraper.js
new file mode 100755
index 0000000..bc68481
--- /dev/null
+++ b/notifier/subject_twitter_scraper.js
@@ -0,0 +1,61 @@
+/*** BEGIN LICENSE BLOCK {{{
+ Copyright (c) 2008 suVene<suvene@zeromemory.info>
+
+ distributable under the terms of an MIT-style license.
+ http://www.opensource.jp/licenses/mit-license.html
+}}} END LICENSE BLOCK ***/
+// PLUGIN_INFO//{{{
+var PLUGIN_INFO =
+<VimperatorPlugin>
+ <name>{NAME}</name>
+ <description>Twitter change notice(need login).</description>
+ <description lang="ja">Twitter変更通知(ログイン済みであること)。</description>
+ <author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author>
+ <version>0.1.0</version>
+ <license>MIT</license>
+ <minVersion>2.0pre</minVersion>
+ <maxVersion>2.0pre</maxVersion>
+ <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier/subject_twitter.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_twitter_scraper');
+
+var URL = 'http://twitter.com/home';
+
+notifier.subject.register(notifier.SubjectHttp, {
+ interval: 60,
+ options: {
+ url: URL,
+ headers: null,
+ extra: {}
+ },
+ parse: function(res) {
+ // if (this.count == 0) return []; // for debug
+ var doc = res.getHTMLDocument('id("timeline_body")/tr[@class=contains(concat(" ", @class, " "), " hentry ")]');
+ return doc;
+ },
+ diff: function(cache, parsed) {
+ var self = this;
+ return parsed.filter(function(element)
+ !cache.some(function(c) self.getContent(c) == self.getContent(element)));
+ },
+ getContent: function(element)
+ $U.getFirstNodeFromXPath('descendant::span[@class="entry-content"]', element).textContent,
+ buildMessages: function(diff) {
+ return diff.map($U.bind(this, function(d) {
+ var permalink = $U.getFirstNodeFromXPath('descendant::a[@class="entry-date"]', d);
+ return new notifier.Message('Twitter', $U.xmlSerialize(d), permalink)
+ }));
+ }
+});
+
+})();
+// vim: set fdm=marker sw=4 ts=4 sts=0 et:
+