-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent-script.js
More file actions
29 lines (25 loc) · 1021 Bytes
/
Copy pathcontent-script.js
File metadata and controls
29 lines (25 loc) · 1021 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
29
chrome.storage.sync.get('config', ({ config }) => {
if (config == null) {
return
}
var config = JSON.parse(config)
// Does the current URL contain one of the keys in the config?
for (const [key, value] of Object.entries(config)) {
if (window.location.href.includes(key)) {
// Create a MutationObserver to wait for the element to be added to the DOM
const observer = new MutationObserver((mutations, obs) => {
const element = document.getElementById('awsc-nav-header');
if (element) {
var navBar = element.getElementsByTagName('nav')
navBar[0].style.backgroundColor = value;
obs.disconnect(); // Stop observing once the element is found
}
});
// Start observing the document for changes
observer.observe(document, {
childList: true,
subtree: true
});
}
}
});