-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
43 lines (31 loc) · 876 Bytes
/
content.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
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
const head = document.querySelector('head');
let styles = `
button:focus,
button:hover,
input:focus,
input:hover,
a:focus,
a:hover,
[tabindex="0"]:focus,
[tabindex="0"]:hover,
select:focus,
select:hover,
textarea:focus,
textarea:hover {
outline: 5px dotted ${request.message} !important;
outline-offset: 5px !important;
}
`;
const styleTag = document.createElement("style");
// add special data attr for FV
styleTag.classList.add('focusvis--styles')
if (styleTag.styleSheet) {
styleTag.styleSheet.cssText = styles;
} else {
styleTag.appendChild(document.createTextNode(styles));
}
head.appendChild(styleTag);
console.log(`Outline color set to: ${request.message}`);
return true;
});