-
Notifications
You must be signed in to change notification settings - Fork 460
/
Copy pathtabs.js
34 lines (32 loc) · 998 Bytes
/
tabs.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
/**
* Copyright (c) 2011 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
function sendKeyToAllTabs(keyStr) {
chrome.windows.getAll({'populate': true}, function(windows) {
for (var i = 0; i < windows.length; i++) {
var tabs = windows[i].tabs;
for (var j = 0; j < tabs.length; j++) {
chrome.tabs.sendRequest(
tabs[j].id,
{'key': keyStr});
}
}
});
}
function loadContentScriptInAllTabs() {
chrome.windows.getAll({'populate': true}, function(windows) {
for (var i = 0; i < windows.length; i++) {
var tabs = windows[i].tabs;
for (var j = 0; j < tabs.length; j++) {
chrome.tabs.executeScript(
tabs[j].id,
{file: 'keycodes.js', allFrames: true});
chrome.tabs.executeScript(
tabs[j].id,
{file: 'content_script.js', allFrames: true});
}
}
});
}