Repository navigation
Expand file tree
/
Copy pathbackground.js
More file actions
64 lines (59 loc) · 2.09 KB
/
Copy pathbackground.js
File metadata and controls
64 lines (59 loc) · 2.09 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
55
56
57
58
59
60
61
62
63
64
console.log('background running...');
// function getStorageData(key) {
// return new Promise(function (resolve, reject) {
// chrome.storage.local.get(key, function (result) {
// if (chrome.runtime.lastError) {
// reject(chrome.runtime.lastError);
// } else {
// resolve(result);
// }
// });
// });
// }
// function setStorageData(key, value) {
// return new Promise(function (resolve, reject) {
// var obj = {};
// obj[key] = value;
// chrome.storage.local.set(obj, function () {
// if (chrome.runtime.lastError) {
// reject(chrome.runtime.lastError);
// } else {
// resolve();
// }
// });
// });
// }
// chrome.action.onClicked.addListener((tab) => {
// console.log(tab);
// chrome.storage.local.get('state', function (result) {
// if (chrome.runtime.lastError) {
// console.error(chrome.runtime.lastError);
// } else {
// // Pass the data to the main webpage using sendMessage
// chrome.runtime.sendMessage({ data: result.state });
// }
// });
// // getStorageData('state')
// // .then(function (result) {
// // if (result == undefined) {
// // setStorageData('state', false)
// // .then(function () {
// // console.log('Value saved successfully');
// // })
// // .catch(function (error) {
// // console.error(error);
// // });
// // result = false;
// // }
// // console.log(result);
// // })
// // .catch(function (error) {
// // console.error(error);
// // });
// });
// chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
// if (message.type === 'myMessage') {
// console.log('Received message:', message.data);
// // Do something with the message data
// }
// });