aboutsummaryrefslogtreecommitdiffstats
path: root/nicovideo_comment.js
blob: 4157649e1496693cc8667543399a384316dc0df2 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
 * ==VimperatorPlugin==
 * @name           nicovideo_comment.js
 * @description    This plugin allows you to fill in the comment form for NICO NICO DOUGA.
 * @description-ja ニコニコ動画のコメント欄を入力
 * @minVersion     0.6pre
 * @author         otsune
 * @version        0.2
 * ==/VimperatorPlugin==
 *
 * Usage:
 * :nico {String}             -> Fill comment form
 * :nico! {String}            -> Fill mail form
 */
(function(){

liberator.commands.addUserCommand(['nico'],'Fill comment form in nicovideo',
    function(arg, special){
        var flvp = window.content.document.getElementById('flvplayer'); 
        var form = special ? 'MailInput.text' : 'ChatInput.text' ;
        flvp.wrappedJSObject.SetVariable(form, arg.toString() );
    },{
        bang: true,
        completer: function(filter, special){
            var templates = [];
            var commands = [
                'ue',
                'shita',
                'big',
                'medium',
                'small',
                'white',
                'red',
                'pink',
                'orange',
                'yellow',
                'green',
                'cyan',
                'blue',
                'purple',
                '184',
                'sage'
            ];
            var premiumcommands = [
                'invisible',
                'niconicowhite',
                'truered',
                'passionorange',
                'madyellow',
                'elementalgreen',
                'marineblue',
                'nobleviolet',
                'black'
            ];
            if (special){
                commands.forEach(function(command){
                    if (command[0].indexOf(filter.toLowerCase()) === 0){
                        templates.push(command);
                    }
                });
            }
            if (special && !(flvp.GetVariable('premiumNo')) ){
                premiumcommands.forEach(function(premiumcommand){
                    if (premiumcommand[0].indexOf(filter.toLowerCase()) === 0){
                        templates.push(premiumcommand);
                    }
                });
            }

            return [0, templates];
        }
    }
);

})();

// vim: set fdm=marker sw=4 ts=4 et:
ss="kd">let index = 0; let url = util.stringToURLArray(url).toString(); for each ( [,tab] in tabs.browsers ) { if(url == tab.currentURI.spec){ tabs.select(index); return true; } ++index; } return false; } "open tabopen edit".split(/\s/).forEach( function (name) { let command = commands.get(name); if (!command) return; U.around( command, "action", function (next, args) { let url = args[0].string; if (!(url && jump(url))) return next(); } ); } ); //buffer.followLink()を変更 //hint-a-hint時[f,F]に対象のタブが既に開いてあったらjump let (ignore = false) { let ignoreBlock = function (block) { ignore = true; let result = block(); ignore = false; return result; }; U.around( buffer, "followLink", function (next, args) { return ignoreBlock(function () { let [elem,] = args; let url = elem.href; if (!(url && jump(url))){ liberator.echo("Now Loading... " + url); return next(); } }); } ); document.addEventListener( 'click', function (event) { if (ignore) return; let e = event.target; if (e && e.tagName.match(/^a$/i) && e.href && jump(e.href)) { event.preventDefault(); event.stopPropagation(); } }, true ); } })();