forked from UiPath/uipath-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextra.js
More file actions
41 lines (34 loc) · 1.15 KB
/
Copy pathextra.js
File metadata and controls
41 lines (34 loc) · 1.15 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
function updateThemePictures() {
const body = document.body;
const mediaAttr = body.getAttribute("data-md-color-media") || "";
const isDark = mediaAttr.includes("dark");
const pictures = document.querySelectorAll("picture");
pictures.forEach((picture) => {
const darkSrc = picture.getAttribute("data-dark");
const lightSrc = picture.getAttribute("data-light");
const source = picture.querySelector("source");
const img = picture.querySelector("img");
if (isDark) {
source.media = "all";
source.srcset = darkSrc;
img.src = darkSrc;
} else {
source.media = "not all";
source.srcset = lightSrc;
img.src = lightSrc;
}
});
}
// Run on load
updateThemePictures();
// Watch for changes to the theme
const observer = new MutationObserver(updateThemePictures);
observer.observe(document.body, {
attributes: true,
attributeFilter: ["data-md-color-media"],
});
document$.subscribe(() => {
document.querySelectorAll(".headerlink").forEach((link) => {
link.setAttribute("data-clipboard-text", link.href);
});
});