Skip to content

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hinakhadim committed Nov 28, 2024
1 parent da6643b commit c095547
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions src/ThemeToggleButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ const ThemeToggleButton = () => {

const getCookieOptions = (serverURL) => ({ domain: serverURL.hostname, path: '/', expires: getCookieExpiry() });

const addDarkThemeToIframes = () => {
const addDarkThemeToIframes = () => {
const iframes = document.getElementsByTagName('iframe');
const iframesLength = iframes.length;

Check warning on line 23 in src/ThemeToggleButton.jsx

View check run for this annotation

Codecov / codecov/patch

src/ThemeToggleButton.jsx#L22-L23

Added lines #L22 - L23 were not covered by tests
if (iframesLength > 0){
Array.from({length: iframesLength}).forEach((_, ind)=>{
let style = document.createElement('style');
style.textContent =
'body {' +
' background-color: #0D0D0E;' +
' color: #ccc;' +
'}'
;
if (iframes[ind].contentDocument) {iframes[ind].contentDocument.head.appendChild(style);}
});
if (iframesLength > 0) {
Array.from({ length: iframesLength }).forEach((_, ind) => {
const style = document.createElement('style');
style.textContent = `

Check warning on line 27 in src/ThemeToggleButton.jsx

View check run for this annotation

Codecov / codecov/patch

src/ThemeToggleButton.jsx#L25-L27

Added lines #L25 - L27 were not covered by tests
body{
background-color: #0D0D0E;
color: #ccc;
}`;
if (iframes[ind].contentDocument) { iframes[ind].contentDocument.head.appendChild(style); }
});
}
};

Expand All @@ -40,17 +39,15 @@ const ThemeToggleButton = () => {
const iframesLength = iframes.length;

Check warning on line 39 in src/ThemeToggleButton.jsx

View check run for this annotation

Codecov / codecov/patch

src/ThemeToggleButton.jsx#L38-L39

Added lines #L38 - L39 were not covered by tests

Array.from({ length: iframesLength }).forEach((_, ind) => {

Check warning on line 41 in src/ThemeToggleButton.jsx

View check run for this annotation

Codecov / codecov/patch

src/ThemeToggleButton.jsx#L41

Added line #L41 was not covered by tests
if (iframes[ind].contentDocument) {
const iframeHead = iframes[ind].contentDocument.head;
const styleTag = Array.from(iframeHead.querySelectorAll('style')).find(
(style) =>
style.textContent.includes('background-color: #0D0D0E;') &&
style.textContent.includes('color: #ccc;')
);
if (styleTag) {
styleTag.remove();
}
if (iframes[ind].contentDocument) {
const iframeHead = iframes[ind].contentDocument.head;
const styleTag = Array.from(iframeHead.querySelectorAll('style')).find(

Check warning on line 44 in src/ThemeToggleButton.jsx

View check run for this annotation

Codecov / codecov/patch

src/ThemeToggleButton.jsx#L43-L44

Added lines #L43 - L44 were not covered by tests
(style) => style.textContent.includes('background-color: #0D0D0E;') && style.textContent.includes('color: #ccc;'),
);
if (styleTag) {
styleTag.remove();

Check warning on line 48 in src/ThemeToggleButton.jsx

View check run for this annotation

Codecov / codecov/patch

src/ThemeToggleButton.jsx#L48

Added line #L48 was not covered by tests
}
}
});
};

Expand Down

0 comments on commit c095547

Please sign in to comment.