-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
28 lines (28 loc) · 766 Bytes
/
background.js
File metadata and controls
28 lines (28 loc) · 766 Bytes
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
// whether or not columns mode is active
var useColumns = true;
// send messages when the button is clicked
chrome.browserAction.onClicked.addListener(function(tab) {
// toggle flag
var message;
if (useColumns) {
message = "stop";
useColumns = false;
} else {
message = "start";
useColumns = true;
}
// alert content scripts
chrome.tabs.query({url: "*://workflowy.com/*"}, function(tabs) {
tabs.forEach(function(tab) {
if (tab.url.match(/.*\.com\/#\/.*/)) {
chrome.tabs.sendMessage(tab.id, message, null);
}
});
});
// toggle icon
if (useColumns) {
chrome.browserAction.setIcon({ path: 'icons/icon_38.png' });
} else {
chrome.browserAction.setIcon({ path: 'icons/inactive_38.png' });
}
});