Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 54 additions & 7 deletions webpage-assets/js/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,38 @@ window.addEventListener(
? (backColor =
document.getElementsByTagName("body")[0].style.backgroundColor)
: null;
document
.getElementsByTagName("body")[0]
.style.setProperty("background-color", request.backgroundColor);

const existingStyle = document.getElementById('dino-custom-styles');
if (existingStyle) {
existingStyle.remove();
}

const styleElement = document.createElement('style');
styleElement.id = 'dino-custom-styles';
styleElement.textContent = `
html, body, [data-turbo-body], .application-main,
.Box, .Box-body, .markdown-body, .container,
.main-content, .content, .wrapper, .page,
.layout, .section, .panel, .card, .modal {
background-color: ${request.backgroundColor} !important;
}
* {
background-color: transparent !important;
}
html, body, [data-turbo-body], .application-main,
.Box, .Box-body, .markdown-body, .container,
.main-content, .content, .wrapper, .page,
.layout, .section, .panel, .card, .modal {
background-color: ${request.backgroundColor} !important;
}
`;
Comment on lines +185 to +203
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid the global * background reset; it wipes component styling.

* { background-color: transparent !important; } removes backgrounds from buttons, alerts, and code blocks, which can reduce contrast and hide UI state cues. Consider dropping the global reset and relying on container selectors (or limiting the reset only to container elements).

🛠️ Suggested change (remove the global reset + duplicate block)
         styleElement.textContent = `
           html, body, [data-turbo-body], .application-main, 
           .Box, .Box-body, .markdown-body, .container, 
           .main-content, .content, .wrapper, .page, 
           .layout, .section, .panel, .card, .modal {
             background-color: ${request.backgroundColor} !important;
           }
-          * {
-            background-color: transparent !important;
-          }
-          html, body, [data-turbo-body], .application-main, 
-          .Box, .Box-body, .markdown-body, .container, 
-          .main-content, .content, .wrapper, .page, 
-          .layout, .section, .panel, .card, .modal {
-            background-color: ${request.backgroundColor} !important;
-          }
         `;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const styleElement = document.createElement('style');
styleElement.id = 'dino-custom-styles';
styleElement.textContent = `
html, body, [data-turbo-body], .application-main,
.Box, .Box-body, .markdown-body, .container,
.main-content, .content, .wrapper, .page,
.layout, .section, .panel, .card, .modal {
background-color: ${request.backgroundColor} !important;
}
* {
background-color: transparent !important;
}
html, body, [data-turbo-body], .application-main,
.Box, .Box-body, .markdown-body, .container,
.main-content, .content, .wrapper, .page,
.layout, .section, .panel, .card, .modal {
background-color: ${request.backgroundColor} !important;
}
`;
const styleElement = document.createElement('style');
styleElement.id = 'dino-custom-styles';
styleElement.textContent = `
html, body, [data-turbo-body], .application-main,
.Box, .Box-body, .markdown-body, .container,
.main-content, .content, .wrapper, .page,
.layout, .section, .panel, .card, .modal {
background-color: ${request.backgroundColor} !important;
}
`;
🤖 Prompt for AI Agents
In `@webpage-assets/js/content.js` around lines 185 - 203, Remove the global reset
and duplicate background block in the style built for styleElement: delete the
`* { background-color: transparent !important; }` rule and remove the repeated
selector block so only one set of container selectors is present; ensure you
keep the single container-targeting CSS that applies `background-color:
${request.backgroundColor} !important` (refer to styleElement and
request.backgroundColor) so buttons, alerts, and other components retain their
native backgrounds and states.

document.head.appendChild(styleElement);
} else if (action === "revert-background-color") {
// Remove custom styles
const customStyle = document.getElementById('dino-custom-styles');
if (customStyle) {
customStyle.remove();
}
document
.getElementsByTagName("body")[0]
.style.setProperty("background-color", backColor);
Expand All @@ -188,11 +216,30 @@ window.addEventListener(
fontColor === ""
? (fontColor = document.getElementsByTagName("*")[0].style.fontColor)
: null;
const all = document.getElementsByTagName("*");
for (let i = 0; i < all.length; i++) {
all[i].style.setProperty("color", request.fontColor);
} }

const existingFontStyle = document.getElementById('dino-font-styles');
if (existingFontStyle) {
existingFontStyle.remove();
}

const fontStyleElement = document.createElement('style');
fontStyleElement.id = 'dino-font-styles';
fontStyleElement.textContent = `
*, body, html, .color-fg-default, .Header-link,
.btn, .Link--primary, .Link--secondary, .f1, .f2,
.f3, .f4, .f5, .f6, h1, h2, h3, h4, h5, h6,
p, span, div, a, button, input, textarea, select,
label, li, td, th {
color: ${request.fontColor} !important;
}
`;
document.head.appendChild(fontStyleElement);
}
else if (action === "revert-Font-color") {
const customFontStyle = document.getElementById('dino-font-styles');
if (customFontStyle) {
customFontStyle.remove();
}
const all = document.getElementsByTagName("*")[0];
all.style.setProperty("color", fontColor);

Expand Down