-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
28 lines (25 loc) · 861 Bytes
/
Copy pathbackground.js
File metadata and controls
28 lines (25 loc) · 861 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
// runs when the browser action is clicked or activated via hotkey
chrome.browserAction.onClicked.addListener(function() {
switchToAudioTab();
});
// switch to the first tab that's playing audio
function switchToAudioTab() {
chrome.tabs.query({ "audible": true }, function (result) {
if (result.length>0) chrome.tabs.update(result[0].id, {active: true });
});
}
// create the "Assign Hotkey" button in the browser action's context menu
chrome.contextMenus.removeAll();
chrome.contextMenus.create({
title: "Assign Hotkey",
id: "assign_hotkey",
contexts: ["browser_action"]
});
// clicking the "Assign Hotkey" button opens the extension hotkey window
chrome.contextMenus.onClicked.addListener(function (info) {
if (info.menuItemId=="assign_hotkey") {
chrome.tabs.create({
url: "chrome://extensions/configureCommands"
});
}
});