-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimperatorrc
More file actions
183 lines (161 loc) · 4.66 KB
/
.vimperatorrc
File metadata and controls
183 lines (161 loc) · 4.66 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
" My Vimperator rc
" Created by zhu 2008-08-03
set popups=window
set toolbars=none
noremap <Right> gt
noremap <Left> gT
noremap <C-T> :tb<cr>
"reload vimperatorrc
map ,r :cd<CR>:so .vimperatorrc<CR>
"Show feed button on statusbar
javascript << EOM
(function(){
var feedPanel = document.createElement('statusbarpanel');
var feedButton = document.getElementById('feed-button');
feedPanel.setAttribute('id', 'feed-panel-clone');
feedPanel.appendChild(feedButton.cloneNode(true));
feedButton.parentNode.removeChild(feedButton);
/* document.getElementById('status-bar').insertBefore(
feedPanel, document.getElementById('security-button')
); */
document.getElementById('liberator-statusline').insertBefore(
feedPanel, document.getElementById('liberator-statusline-field-tabcount')
);
})();
EOM
javascript <<EOM
liberator.modules.commands.addUserCommand( ['tb'], 'Toggle Tablist',
function(arg){
with(gBrowser.mTabContainer) {
collapsed ? collapsed = false : collapsed = true;
}
},{
}
);
EOM
"Add mapping 'C-c' copy
javascript <<EOM
liberator.modules.mappings.addUserMap( [liberator.modules.modes.NORMAL], ['<C-c>'],
'Copy selected text or ',
function () {
var sel = liberator.modules.buffer.getCurrentWord();
if (sel) {
liberator.modules.util.copyToClipboard(sel, true);
liberator.echo ( 'Yanked: ' + liberator.modules.util.escapeHTML(sel) );
}
}, {}
);
EOM
"Add a bit.ly url shorter
:javascript << EOM
function Bitly(url){
try {
var xml = new XMLHttpRequest();
if ( url == null ) {
url = liberator.modules.buffer.URL; //get the current URL
}
xml.open("GET", "http://api.bit.ly/shorten?version=2.0.1&login=zzn2&apiKey=R_7fcf1d8a566f332f8b08b2c3171c9fca&longUrl="+url, false );
xml.send(null);
var json = JSON.parse(xml.responseText);
if ( json.errorCode != 0 ) {
throw("error:"+json.errorMessage);
}
for ( i in json.results ) {
return json.results[i].shortUrl;
}
} catch(ex) {
alert(ex.errorCode);
}
}
function geturl() {
alert ( liberator.modules.buffer.URL );
}
liberator.modules.commands.addUserCommand( ['shorten'], 'Bit.ly Shorten',
function(args) {
if ( args == '' ) {
alert( 'no param' );
} else {
try {
// Bitly(args);
geturl();
}
catch(ex) {
}
}
},{
options: true
}
);
EOM
"Add a command to post twitter
:javascript << EOM
function sayTwitter(username,password,stat){
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://twitter.com/statuses/update.json", false );//, username, password );
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded' );
xhr.setRequestHeader('X-Twitter-Client', 'zzn2' );
xhr.setRequestHeader('X-Twitter-Client-Version', '0.1' );
xhr.setRequestHeader('X-Twitter-Client-URL', 'http://twitter.com/zzn2' );
xhr.setRequestHeader('Authorization', 'Basic ' + btoa(username + ":" + password));
xhr.onreadystatechange = function() {
alert ( "readyState:" + readyState );
alert ( xhr.responseText );
};
var tweet = stat.string;
if ( tweet.match(/\url/i)) {
tweet = tweet.replace( "\\url", Bitly(null) ) ;
}
if( confirm( tweet ) ) {
xhr.send("status=" + encodeURIComponent(tweet));
}
}
liberator.modules.commands.addUserCommand( ['twitter'], 'Say Twitter',
function(args) {
if ( args == '' ) {
alert( 'no param' );
} else {
try {
var passwordManager = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
var logins = passwordManager.findLogins({}, 'http://twitter.com', 'https://twitter.com', null);
if ( logins.length) {
[username, password] = [logins[0].username, logins[0].password];
sayTwitter(username, password, args);
} else {
alert ( "Twitter: account not found" );
}
}
catch(ex) {
}
}
},{
options: true
}
);
EOM
"Show tab button on statusbar
:javascript << EOM
(function(){
for ( i=0; i<liberator.modules.tabs.count; i++)
{
xul= liberator.modules.tabs.getTab(i)
// var tabPanel = document.createElement('image');
// tabPanel.setAttribute('src', 'http://vimperator.org/trac/chrome/site/favicon.png');
var tabPanel = document.createElement('button');
tabPanel.setAttribute('label', xul.label );
/* document.getElementById('liberator-statusline').insertBefore(
tabPanel, document.getElementById('liberator-statusline-field-tabcount')
); */
}
})();
/*
var feedPanel = document.createElement('statusbarpanel');
var feedButton = document.getElementById('feed-button');
feedPanel.setAttribute('id', 'feed-panel-clone');
feedPanel.appendChild(feedButton.cloneNode(true));
feedButton.parentNode.removeChild(feedButton);
document.getElementById('status-bar').insertBefore(
feedPanel, document.getElementById('security-button')
);
*/
EOM
echo ".vimperatorrc sourced!"