-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackground.js
74 lines (69 loc) · 3.32 KB
/
background.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
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
65
66
67
68
69
70
71
72
73
74
// Listen for messages from stockPage.js
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if (message.disableStockRefreshChecked !== undefined) {
// Store switch status in Chrome storage
chrome.storage.sync.set({ 'disableStockRefreshChecked': message.disableStockRefreshChecked });
console.log('disable timer button: ' + message.disableStockRefreshChecked);
}
else{
console.log('disable timer button - message undefined');
}
});
// Listen for enableEcnomoyMode button
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if (message.enableEconomyModeChecked !== undefined) {
// Store switch status in Chrome storage
chrome.storage.sync.set({ 'enableEconomyModeChecked': message.enableEconomyModeChecked });
console.log('enable economy button: ' + message.enableEconomyModeChecked);
}
else{
console.log('enable economy button - message undefined');
}
});
//listen for stock exchange values
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
// Check if the message contains the value for exchangeWood
if (message.exchangeWood !== undefined) {
// Save exchangeWood to chrome.storage.sync
chrome.storage.sync.set({ exchangeWood: message.exchangeWood }, function() {
if (chrome.runtime.lastError) {
console.error("Error saving exchangeWood to chrome.storage.sync:", chrome.runtime.lastError);
} else {
console.log("exchangeWood saved to chrome.storage.sync successfully.");
}
});
}
// Check if the message contains the value for exchangeStone
if (message.exchangeStone !== undefined) {
// Save exchangeStone to chrome.storage.sync
chrome.storage.sync.set({ exchangeStone: message.exchangeStone }, function() {
if (chrome.runtime.lastError) {
console.error("Error saving exchangeStone to chrome.storage.sync:", chrome.runtime.lastError);
} else {
console.log("exchangeStone saved to chrome.storage.sync successfully.");
}
});
}
// Check if the message contains the value for exchangeIron
if (message.exchangeIron !== undefined) {
// Save exchangeIron to chrome.storage.sync
chrome.storage.sync.set({ exchangeIron: message.exchangeIron }, function() {
if (chrome.runtime.lastError) {
console.error("Error saving exchangeIron to chrome.storage.sync:", chrome.runtime.lastError);
} else {
console.log("exchangeIron saved to chrome.storage.sync successfully.");
}
});
}
// Check if the message contains the value for storageCapacity
if (message.storageCapacity !== undefined) {
// Save storageCapacity to chrome.storage.sync
chrome.storage.sync.set({ storageCapacity: message.storageCapacity }, function() {
if (chrome.runtime.lastError) {
console.error("Error saving storageCapacity to chrome.storage.sync:", chrome.runtime.lastError);
} else {
console.log("storageCapacity saved to chrome.storage.sync successfully.");
}
});
}
});