-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
28 lines (25 loc) · 969 Bytes
/
popup.js
File metadata and controls
28 lines (25 loc) · 969 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
'use strict';
let startTracking = document.getElementById('startTracking');
let stopTracking = document.getElementById('stopTracking');
//start tracking the active tab
startTracking.onclick = function (element) {
console.log("Start Clicked")
// retrieve current tab's id and window
let tabId;
let windowId;
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
tabId = tabs[0].id
windowId = tabs[0].windowId
});
// store the tabId and windowId for use by extension
chrome.storage.sync.set({ 'tabId': tabId, 'windowId': windowId }, function () {
console.log(`Tracking started with tabId: ${tabId} and windowId: ${windowId}`)
})
};
stopTracking.onclick = function (element) {
console.log("Stop Clicked")
// remove tracked tab and window ids from storage
chrome.storage.sync.set({ 'tabId': -1, 'windowId': -1 }, function () {
console.log(`Tracking stopped`)
})
};