forked from vimpr/vimperator-plugins
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gbmark.js
44 lines (43 loc) · 1.41 KB
/
gbmark.js
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
// INFO //
var INFO =
<plugin name="gbmark.js" version="0.2"
summary="Add Google Bookmark."
href="http://github.com/vimpr/vimperator-plugins/blob/master/gbmark.js"
xmlns="http://vimperator.org/namespaces/liberator">
<author email="mitsugu.oyama@gmail.com">Mitsugu Oyama</author>
<license href="http://opensource.org/licenses/mit-license.php">MIT</license>
<project name="Vimperator" minVersion="2.3"/>
<p>Add Google Bookmark.</p>
<item>
<tags>'gbmark.js'</tags>
<spec>:gbmark</spec>
<description>
<p>Add Google Bookmark.</p>
</description>
</item>
</plugin>;
(function(){
commands.addUserCommand(
['gbmark'],
'Add Google Bookmark.',
function(){
let Cc=Components.classes;
let Ci=Components.interfaces;
let doc=gBrowser.selectedBrowser.contentDocument;
let strEndPoint='http://www.google.com/bookmarks/mark?op=add&bkmk=';
let strUrl=doc.URL;
let strTitle=doc.title;
let strSelect=doc.defaultView.getSelection().toString();
let strUri;
if(1<strSelect.length){
strUri=strEndPoint+encodeURIComponent(strUrl)
+'&title='+encodeURIComponent(strTitle)
+'&annotation='+encodeURIComponent(strSelect)+'&hl=ja';
}else{
strUri=strEndPoint+encodeURIComponent(strUrl)
+'&title='+encodeURIComponent(strTitle)+'&hl=ja';
}
gBrowser.addTab(strUri);
}
);
})();