-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
54 lines (50 loc) · 1.62 KB
/
main.js
File metadata and controls
54 lines (50 loc) · 1.62 KB
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
// pins current tab, and keeps focus.
chrome.commands.onCommand.addListener(function(command) {
if (command == "toggle-pin") {
// Get the currently selected tab
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
// Toggle the pinned status
chrome.tabs.getSelected(null, function(tab) {
console.log(tab);
});
var current = tabs[0];
chrome.tabs.update(current.id, { pinned: !current.pinned });
});
} else if (command == "toggle-browser-action") {
}
});
// assigns query( assigns first arg to empty obj, second to callback)
chrome.tabs.query({}, function(tabs) {
// in cb declare new obj
const objTabs = {};
const urlCache = {};
const urlMetaCache = {};
// loop through obj
for (let obj of tabs) {
let lowTitle = obj.title;
objTabs[obj.id] = lowTitle.toLowerCase();
urlCache[obj.id] = [obj.favIconUrl, obj.title, obj.url];
urlMetaCache[obj.id] = [obj.selected, obj.highlighted, obj.title];
// arrayTabs.push(obj["title"]);
}
console.log("begin our loop test");
for (let el in objTabs) {
console.log(objTabs[el]);
}
console.log("urlCache:", urlCache);
// console.log("urlMetaCache:", urlMetaCache);
// console.log(objTabs);
// console.log(tabs);
});
function doInCurrentTab(tabCallback) {
chrome.tabs.query(
// execute code only in current window if properties are true below
{ currentWindow: true, active: true },
function(tabArray) {
// added here
var updateProperties = { active: true };
chrome.tabs.update(tabId, updateProperties, tab => {});
tabCallback(tabArray[0]);
}
);
}