A Chrome extension that allows you to adjust, customize, and test website styles. Enhance UI, test CSS resilience, and apply accessibility features with ease.
- Dark Mode - Force dark mode on any website
- Focus Outlines - Force visible focus outlines for accessibility testing
- System Font - Replace all fonts with system fonts
- Hide Images & Media - Hide all images, videos, and media elements
- Layout Outlines - Visualize page structure with colored outlines
- Nerdy Mode - Enhance UI with polished, professional styling
- Random Colors - Apply random colors to break contrast
- Randomize Everything - Apply random styles to test CSS resilience
- Soft Reset - Revert all toggleable changes without reloading
- Reload Page - Full page reload
- Clone or download this repository
- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" (toggle in top right)
- Click "Load unpacked"
- Select the extension directory
- Make changes to the source files
- Click the refresh icon on the extension card in
chrome://extensions/ - Test your changes on any webpage
web-style-tweaker/
├── manifest.json # Extension manifest (Chrome Web Extension)
├── popup.html # Extension popup UI
├── popup.js # Popup logic and message handling
├── content.js # Content script (injected into web pages)
├── nerdy-mode.css # Enhanced UI styles for Nerdy Mode
└── README.md # This file
Defines the extension metadata, permissions, and web accessible resources.
Note: Currently set to manifest_version: 1, but should be 3 for modern Chrome extensions. Update this if you encounter compatibility issues.
- popup.html: The extension's popup UI with all control buttons
- popup.js: Handles user interactions and communicates with content script via Chrome messaging API
The main content script that:
- Injects styles into web pages
- Manages toggle states
- Handles style application and removal
- Provides API for style manipulation
External stylesheet loaded dynamically for the Nerdy Mode feature.
The extension uses Chrome's messaging API for communication between popup and content script:
CSS_STRESS_TOGGLE
- Toggle a style feature on/off
- Request:
{ type: 'CSS_STRESS_TOGGLE', test: 'darkMode' } - Response:
{ ok: true, toggledOn: boolean }
CSS_STRESS_RUN_ONCE
- Execute a one-off test
- Request:
{ type: 'CSS_STRESS_RUN_ONCE', test: 'randomColors' } - Response:
{ ok: true }
CSS_STRESS_RESET_SOFT
- Reset all toggleable styles
- Request:
{ type: 'CSS_STRESS_RESET_SOFT' } - Response:
{ ok: true }
CSS_STRESS_GET_STATE
- Get current state of all toggles
- Request:
{ type: 'CSS_STRESS_GET_STATE' } - Response:
{ ok: true, states: { darkMode: boolean, ... } }
Styles are injected using <style> elements with unique IDs:
- Prefix:
css-stress-style- - Example:
css-stress-style-darkmode - Stored in
state.stylesMap for tracking
The content script maintains state in window.__CSS_STRESS__:
{
state: {
styles: Map, // Active style elements
toggles: Set // Active toggle keys
},
api: {
toggle: { ... }, // Toggle functions
runOnce: { ... }, // One-off functions
resetSoft: fn // Reset function
}
}- Add the function in
content.js:
function toggleMyFeature() {
return toggleStyle('myfeature', `
/* Your CSS here */
body { background: red !important; }
`);
}- Add to API object:
const api = {
toggle: {
// ... existing
myFeature: toggleMyFeature
}
};- Add button in
popup.html:
<button id="myFeature">My Feature</button>- Add to
toggleConfiginpopup.js:
const toggleConfig = {
// ... existing
myFeature: { id: 'myFeature', off: 'Enable My Feature', on: 'Disable My Feature' }
};- Bind the toggle:
bindToggle('myFeature');- Add to state detection:
['darkMode', 'myFeature', ...].forEach(key => {
states[key] = !!document.getElementById(STYLE_PREFIX + key);
});- Add the function in
content.js:
function myTestOnce() {
// Apply styles directly to elements
document.querySelectorAll('*').forEach(el => {
el.style.transform = 'rotate(5deg)';
});
}- Add to API:
runOnce: {
// ... existing
myTest: myTestOnce
}- Add button and bind in
popup.js:
bind('myTest', () => sendRunOnce('myTest'));For features that use external CSS files (like Nerdy Mode):
- Add to
manifest.jsonweb_accessible_resources:
"web_accessible_resources": [
{
"resources": ["my-feature.css"],
"matches": ["<all_urls>"]
}
]- Load in toggle function:
async function toggleMyFeature() {
const id = STYLE_PREFIX + 'myfeature';
if (state.styles.has(id)) {
removeStyle(id);
return false;
} else {
const cssUrl = chrome.runtime.getURL('my-feature.css');
const response = await fetch(cssUrl);
const css = await response.text();
addStyle(id, css);
return true;
}
}- Load the extension in Chrome
- Navigate to any website
- Click the extension icon
- Test each feature:
- Toggle features should show active state (green highlight)
- One-off tests should apply immediately
- Soft Reset should revert all toggles
- Reload should fully reset the page
- Chrome/Chromium (Manifest V3)
- Edge (Chromium-based)
- Other Chromium-based browsers
Note: Currently uses Manifest V1 syntax. Update to V3 for future compatibility.
activeTab- Access to the currently active tabscripting- Inject content scripts into web pages
- Check browser console for errors
- Verify content script is injected (
window.__CSS_STRESS__exists) - Check that styles aren't being overridden by page styles
- Ensure
CSS_STRESS_GET_STATEmessage handler is working - Check that style IDs match between injection and detection
- Verify file is in
web_accessible_resources - Check file path matches
chrome.runtime.getURL()call - Look for CORS errors in console
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Built for developers and designers who want to test and customize web styles.