Skip to content

resolve style application on GitHub and complex websites#179

Open
soumojit-D48 wants to merge 1 commit intodeveloper-diganta:mainfrom
soumojit-D48:fix/174-github-style-application
Open

resolve style application on GitHub and complex websites#179
soumojit-D48 wants to merge 1 commit intodeveloper-diganta:mainfrom
soumojit-D48:fix/174-github-style-application

Conversation

@soumojit-D48
Copy link

@soumojit-D48 soumojit-D48 commented Feb 5, 2026

Fixes #174

Description

Fixed the issue where selected style options (background color, font color) were not being applied on GitHub and other complex websites.

Problem: GitHub's nested DOM structure and high CSS specificity prevented Dino's style changes from working properly. The existing approach only targeted basic elements like body and *, which was insufficient.

Solution Implemented:

  • CSS Injection System: Created comprehensive <style> elements with unique IDs for proper cleanup
  • High-Specificity Selectors: Added GitHub-specific container targeting including .application-main, .Box, .Box-body, .markdown-body, .container, .main-content, etc.
  • Important Declarations: Used !important to override GitHub's existing styles
  • Font Color Coverage: Enhanced font color application to target all GitHub UI components like .color-fg-default, .Header-link, .btn, .Link--primary, etc.
  • Style Management: Added proper removal of custom styles when reverting changes

Files Modified:

  • webpage-assets/js/content.js (lines 174-241): Enhanced backgroundColor and fontColor actions

The fix ensures that background and font color changes now work correctly across all GitHub pages and similar complex websites with nested structures.

Screenshots

Before
Screenshot 2026-02-06 001150

After
Screenshot 2026-02-06 001517

Before Fix:

  • GitHub repository page with background color selected but NOT applied
  • Extension popup showing selected color
  • GitHub still showing default white background

After Fix:

  • Same GitHub repository page with background color SUCCESSFULLY applied
  • All nested containers (header, sidebar, main content) showing the new color
  • Font color changes working on GitHub links and buttons

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

I am a Apertre3.0 Participant

  • Name: Soumojit Das
  • Discord Username: soumojit010
  • I have included the issue number in my PR

Summary by CodeRabbit

  • Refactor
    • Updated how background color and font color customizations are applied to the webpage.

@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

This change refactors the color theming mechanism in content.js by replacing direct inline style updates with dynamic CSS injection. It creates and removes style elements with specific IDs to apply background and font colors using !important declarations, centralizing theme application and addressing styling issues with nested elements.

Changes

Cohort / File(s) Summary
Color Theming via CSS Injection
webpage-assets/js/content.js
Replaces inline style updates with dynamic CSS injection for background and font colors. Creates style elements with !important declarations to ensure colors apply across nested elements. Removes previous inline styles when reverting colors. Addresses issue where selected style changes weren't applying to certain website structures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 CSS sprites dance in the DOM's dark night,
Injecting colors with `!important` might!
No nested tag shall hide or run away,
From the rabbit's themed refresh today! 🌈✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'resolve style application on GitHub and complex websites' accurately captures the main objective of fixing style application issues on complex DOM structures, which directly aligns with the core change in the PR.
Description check ✅ Passed The PR description is comprehensive, including issue reference, detailed problem/solution explanation, code changes summary, before/after screenshots, proper categorization as bug fix, and completed checklist items.
Linked Issues check ✅ Passed The code changes fully address issue #174 by implementing CSS injection with high-specificity selectors and !important declarations to override complex site styles, ensuring style options are now applied on GitHub and similar nested DOM structures.
Out of Scope Changes check ✅ Passed All changes in webpage-assets/js/content.js are scoped to fixing the backgroundColor and fontColor style application issues on complex websites as specified in issue #174, with no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@webpage-assets/js/content.js`:
- Around line 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.

Comment on lines +185 to +203
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;
}
`;
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.

@soumojit-D48
Copy link
Author

Hi @developer-diganta, Check this PR Helpful or not, let me know, Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Selected option is not being applied

1 participant