-
Notifications
You must be signed in to change notification settings - Fork 5
/
background.js
39 lines (36 loc) · 1.31 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
let managedIcon = {
16: "managed_16.png",
32: "managed_32.png",
64: "managed_64.png"
}
let unmanagedIcon = {
16: "unmanaged_16.png",
32: "unmanaged_32.png",
64: "unmanaged_64.png"
}
let useNativeSRGB;
let useWebRenderCompositor;
function updateIcon() {
browser.browserSettings.colorManagement.useNativeSRGB.get({}).then(result1 => {
useNativeSRGB = result1.value;
browser.browserSettings.colorManagement.useWebRenderCompositor.get({}).then(result2 => {
useWebRenderCompositor = result2.value;
if (useNativeSRGB || useWebRenderCompositor) {
browser.browserAction.setIcon({path: managedIcon});
browser.browserAction.setTitle({title: "Color pass-through is disabled."});
chrome.storage.local.set({"extended_color_management_state": "disabled"});
} else {
browser.browserAction.setIcon({path: unmanagedIcon});
browser.browserAction.setTitle({title: "Color pass-through is enabled."});
chrome.storage.local.set({"extended_color_management_state": "enabled"});
}
});
});
}
// We only update the icon at startup since the browser needs to be restarted for changes to take effect.
updateIcon();
browser.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
sendResponse({useNativeSRGB, useWebRenderCompositor});
}
);