-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (52 loc) · 1.71 KB
/
index.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
var self = require('sdk/self');
var tabs = require('sdk/tabs');
var workers = require('sdk/content/worker');
var {ActionButton} = require('sdk/ui/button/action');
var {openDialog} = require('sdk/window/utils');
var base64 = require('sdk/base64');
var toolbarButton = ActionButton({
id: 'wallabag-toolbar-button',
label: 'Bag it !',
icon: {
'16': self.data.url('icon-16.png'),
'32': self.data.url('icon-32.png'),
'64': self.data.url('icon-64.png')
}
});
var wallabag = {
buttonClick: function wallabagButtonClick(state) {
var worker = tabs.activeTab.attach({
contentScriptFile: self.data.url('js/wallabag-get-infos.js')
});
worker.port.emit('ping');
worker.port.on('pong', wallabag.postLink);
},
postLink: function wallabagPostLink(linkInfo) {
var wallabagUrl = require('sdk/simple-prefs').prefs.wallabagUrl;
var height = require('sdk/simple-prefs').prefs.wallabagHeight;
var width = require('sdk/simple-prefs').prefs.wallabagWidth;
var url = linkInfo.wallaUrl;
var title = linkInfo.wallaTitle;
var description = linkInfo.wallaDescription;
var GET = [
'action=add',
'autoclose=true',
'url='+base64.encode(url),
];
var features = [
'height='+height,
'width='+width,
'centerscreen=yes',
'toolbar=no',
'menubar=no',
'scrollbars=no',
'status=no',
'dialog'
];
openDialog({
url: wallabagUrl+"?"+GET.join('&'),
features: features.join(',')
});
}
};
toolbarButton.on('click', wallabag.buttonClick);