-
Notifications
You must be signed in to change notification settings - Fork 59
/
button.js
56 lines (43 loc) · 1.17 KB
/
button.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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/*jshint esnext:true */
/*global addon:true, dump:true */
"use strict";
var privateBrowsing = require('sdk/private-browsing');
var tabs = require('sdk/tabs');
var ui = require('sdk/ui');
var whimsIcon = {
'18': './whimsycorn-18.png',
'32': './whimsycorn-32.png',
'36': './whimsycorn-36.png',
'48': './whimsycorn-48.png',
'64': './whimsycorn-64.png'
};
var dimsIcon = {
'18': './dimsycorn-18.png',
'32': './dimsycorn-32.png',
'36': './dimsycorn-36.png',
'48': './dimsycorn-48.png',
'64': './dimsycorn-64.png'
};
exports.load = function () {
let button = ui.ActionButton({
id: 'whimsy-button',
label: 'Whimsy!',
icon: whimsIcon,
onClick: function (button) {
console.log(button.id, button.label);
}
});
// Listen for tab openings.
tabs.on('activate', function (tab) {
if (privateBrowsing.isPrivate(tab)) {
button.icon = dimsIcon;
} else {
button.icon = whimsIcon;
}
});
};
exports.unload = function () {
};