let PLUGIN_INFO = {NAME} Tombloo integrate plugin Tombloo 統合プラグイン Trapezoid 0.1.1 2.0pre 2.3 https://github.com/vimpr/vimperator-plugins/raw/master/tombloo.js ; (function () { // ts: "T"ombloo "S"ervice let tomblooService; try { tomblooService = getTombloo(); } catch (e) { liberator.log(e.message, 0); return; } with (tomblooService) { commands.addUserCommand( ['tomblooAction'], 'Execute Tombloo actions', function (args) { let f = Tombloo.Service.actions[args.literalArg]; (f instanceof Function) ? f.execute() : liberator.echoerr(args.literalArg + ' is not Tombloo Action.'); }, { literal: 0, completer: function (context) { context.title = ['Tombloo Actions']; let names = Tombloo.Service.actions.names; let candidates = [[n, n] for([, n] in Iterator(names))]; context.completions = candidates.filter( function ($_) this.test($_[0]), new RegExp(context.filter, 'i') ); }, } ); commands.addUserCommand( ['tombloo'], 'Post by Tombloo', function (args) { liberator.log(args.literalArg, 0); let f = Tombloo.Service.extractors[args.literalArg]; (typeof f === 'object') ? Tombloo.Service.share(getContext(), f, args.bang) : liberator.echoerr(args.string + ' is not Tombloo command'); }, { literal: 0, bang: true, completer: function (context) { context.title = ['Tombloo']; let extensions = Tombloo.Service.check(getContext()); let candidates = [[e.name, e.name] for ([, e] in Iterator(extensions))]; context.completions = candidates.filter( function($_) this.test($_[0]), new RegExp(context.filter, 'i') ); } } ); } // with (tomblooService) // helper --- function getTombloo() { const serviceId = '@brasil.to/tombloo-service;1'; if (!Cc[serviceId]) throw new Error('Tombloo is not found. install from http://github.com/to/tombloo/wikis'); return Cc[serviceId].getService().wrappedJSObject; } function getContext() { const doc = window.content.document; const win = window.content.wrappedJSObject; function getTarget() { if (/^http:\/\/reader\.livedoor\.com/.test(buffer.URL)) { let item = win.get_active_item && win.get_active_item(true); return item ? item.element : doc; } else { return doc; } } return implant( implant( { document: doc, window: win, title: doc.title.toString() || '', selection: win.getSelection().toString(), target: getTarget(), //event : event, //mouse : mouse, //menu : gContextMenu, }, {} ), win.location ); } // stuff --- function implant(dst, src, keys){ if (keys) { keys.forEach(function(key) { dst[key] = src[key]; }); } else { for (let key in src) dst[key] = src[key]; } return dst; } })(); // vim:sw=4 ts=4 et: 20'>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 60 61
var PLUGIN_INFO =
<VimperatorPlugin>
<name>{NAME}</name>
<description>Clear highlight or highlight keywords in Hatena Services.</description>
<description lang="ja">はてなダイアリーやグループでハイライトを消したり付けたりできます</description>
<minVersion>2.1a1pre</minVersion>
<maxVersion>2.1a1pre</maxVersion>
<updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/hatena_highlight.js</updateURL>
<author mail="masa138@gmail.com" homepage="http://www.hatena.ne.jp/masa138/">Masayuki KIMURA</author>
<version>0.1</version>
<detail><![CDATA[

== Commands ==
:nohatenahighlight
    ハイライトを無効にします

:hatenahighlight
    ハイライトを有効にします

== Examples ==
Google で検索してはてなにアクセスしたときにハイライトを非表示にしたい場合は
.vimperatrrc に以下のような記述をすると非表示になります
>||
:autocmd PageLoad 'd\.hatena\.ne\.jp' :nohatenahighlight
:autocmd PageLoad 'g\.hatena\.ne\.jp' :nohatenahighlight
||<

]]></detail>
</VimperatorPlugin>;
(function(){
    function toggleHighlight(isClear) {
        var elements = window.content.document.getElementsByTagName('span');
        var highlight = 'highlight';
        var clear     = '_no_highlight_';
        for (var i = 0, length = elements.length; i < length; i++) {
            var element = elements[i];
            if (isClear) {
                if (element.className == highlight) {
                    element.className =  clear;
                }
            } else {
                if (element.className == clear) {
                    element.className =  highlight;
                }
            }
        }
    }

    commands.addUserCommand(["nohatenahighlight"], "Clear Highlight",
        function() {
            toggleHighlight(true);
        }
    );

    commands.addUserCommand(["hatenahighlight"], "Highlight",
        function() {
            toggleHighlight(false);
        }
    );
})();
// vim:sw=4 ts=4 et: