aboutsummaryrefslogtreecommitdiffstats
path: root/notifier/subject_hatelabo_bottle.js
blob: c74756d26ba9f629091e32b90df941ddd9187b9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*** 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>hatena bottle change notice.</description>
    <description lang="ja">はてなボトルの変更通知</description>
    <author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author>
    <version>0.1.2</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_hatelabo_bottle.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_hatelabo_bottle');

var URL = 'http://bottle.hatelabo.jp';

notifier.subject.register(notifier.SubjectHttp, {
    interval: 60,
    options: {
        url: URL,
        headers: null,
        extra: null
    },
    parse: function(res) {
        // 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) {
        return diff.map($U.bind(this, function(d) {
            var permalink = $U.getFirstNodeFromXPath('descendant::a[@class="hatena-star-uri"]', d);
            if (permalink)
                permalink = URL + permalink;
            return new notifier.Message('Hatelabo bottle', $U.xmlSerialize(d), permalink)
        }));
    }
});

})();
// vim: set fdm=marker sw=4 ts=4 sts=0 et:

:reveal_ie_image_mode_normal = 'r': Hints mode for normal version. g:reveal_ie_image_mode_reverse = 'R': Hints mode for reverse version. ]]></detail> <detail lang="ja"><![CDATA[ == Description == IE Ctrl-A 画像を暴く == Global Variables == g:reveal_ie_image_mode_normal = 'r': 通常版のヒントモード g:reveal_ie_image_mode_reverse = 'R': 反対版のヒントモード ]]></detail> </VimperatorPlugin>; // }}} (function () { let ieimg = 'data:image/gif;base64,'+ 'R0lGODlhAgACAIABAF6BvP///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAAEALAAAAAACAAIA'+ 'AAIDRAIFADs='; let modeN = gv('reveal_ie_image_mode_normal', 'r'); let modeR = gv('reveal_ie_image_mode_reverse', 'R'); function gv (name, def) let (v = liberator.globalVariables[name]) (v === undefined ? def : v); function getAbsPosition (elem) { let rect = elem.getBoundingClientRect(); return { x: Math.max((rect.left + content.scrollX), content.scrollX), y: Math.max((rect.top + content.scrollY), content.scrollY), }; } function reveal (elem, sec, zura) { if (sec <= 0) sec = 5; let body = elem.ownerDocument.body; let indicator = elem.ownerDocument.createElement('div'); let pos = getAbsPosition(elem); //let rect = elem.getBoundingClientRect(); indicator.id = 'detect-hidden-indicator'; let style = 'background-image: url(' + ieimg + ');' + //'opacity: 0.8;' + //TODO 'background-repeat: repeat;' + 'z-index: 999;' + 'position: absolute; ' + 'top: ' + (pos.y + (zura ? 1 : 0)) + 'px;' + 'height:' + elem.clientHeight + 'px;'+ 'left: ' + pos.x + 'px;' + 'width: ' + elem.clientWidth + 'px'; indicator.setAttribute('style', style); body.appendChild(indicator); setTimeout(function () body.removeChild(indicator), sec * 1000); } // for debug if (0) { let xpath = '/html/body/div[2]/div[3]/table/tbody/tr/td[2]/div/table/tbody/tr/td[2]/div/img'; let node = buffer.evaluateXPath(xpath).snapshotItem(0); reveal(node, 1); } [ [modeN, false], [modeR, true] ].forEach(function ([mode, zura]) { if (!mode) return; hints.addMode( mode, 'Reveal IE Ctrl-A images.' + (zura ? ' (reverse)' : ''), function (elem, loc, count) { reveal(elem, count, zura); }, function () '//img' ); }); })(); // vim:sw=2 ts=2 et si fdm=marker: