(theme: Theme, isIFrame: boolean, styleSystemControls: boolean)
| 131 | ]; |
| 132 | |
| 133 | export function getModifiedUserAgentStyle(theme: Theme, isIFrame: boolean, styleSystemControls: boolean): string { |
| 134 | const lines: string[] = []; |
| 135 | if (!isIFrame) { |
| 136 | lines.push('html {'); |
| 137 | lines.push(` background-color: ${modifyBackgroundColor({r: 255, g: 255, b: 255}, theme)} !important;`); |
| 138 | lines.push('}'); |
| 139 | } |
| 140 | // color-scheme can change the background of an iframe |
| 141 | // that is supposed to be transparent |
| 142 | if ((__CHROMIUM_MV3__ || isCSSColorSchemePropSupported) && theme.mode === 1) { |
| 143 | lines.push('html {'); |
| 144 | lines.push(` color-scheme: dark !important;`); |
| 145 | lines.push('}'); |
| 146 | lines.push('iframe {'); |
| 147 | lines.push(` color-scheme: dark !important;`); |
| 148 | lines.push('}'); |
| 149 | } |
| 150 | const bgSelectors = joinSelectors(isIFrame ? '' : 'html, body', styleSystemControls ? 'input, textarea, select, button, dialog' : ''); |
| 151 | if (bgSelectors) { |
| 152 | lines.push(`${bgSelectors} {`); |
| 153 | lines.push(` background-color: ${modifyBackgroundColor({r: 255, g: 255, b: 255}, theme)};`); |
| 154 | lines.push('}'); |
| 155 | } |
| 156 | lines.push(`${joinSelectors('html, body', styleSystemControls ? 'input, textarea, select, button' : '')} {`); |
| 157 | lines.push(` border-color: ${modifyBorderColor({r: 76, g: 76, b: 76}, theme)};`); |
| 158 | lines.push(` color: ${modifyForegroundColor({r: 0, g: 0, b: 0}, theme)};`); |
| 159 | lines.push('}'); |
| 160 | lines.push('a {'); |
| 161 | lines.push(` color: ${modifyForegroundColor({r: 0, g: 64, b: 255}, theme)};`); |
| 162 | lines.push('}'); |
| 163 | lines.push('table {'); |
| 164 | lines.push(` border-color: ${modifyBorderColor({r: 128, g: 128, b: 128}, theme)};`); |
| 165 | lines.push('}'); |
| 166 | lines.push('mark {'); |
| 167 | lines.push(` color: ${modifyForegroundColor({r: 0, g: 0, b: 0}, theme)};`); |
| 168 | lines.push('}'); |
| 169 | lines.push('::placeholder {'); |
| 170 | lines.push(` color: ${modifyForegroundColor({r: 169, g: 169, b: 169}, theme)};`); |
| 171 | lines.push('}'); |
| 172 | lines.push('input:-webkit-autofill,'); |
| 173 | lines.push('textarea:-webkit-autofill,'); |
| 174 | lines.push('select:-webkit-autofill {'); |
| 175 | lines.push(` background-color: ${modifyBackgroundColor({r: 250, g: 255, b: 189}, theme)} !important;`); |
| 176 | lines.push(` color: ${modifyForegroundColor({r: 0, g: 0, b: 0}, theme)} !important;`); |
| 177 | lines.push('}'); |
| 178 | if (theme.scrollbarColor && !hostsWithOddScrollbars.includes(location.hostname)) { |
| 179 | lines.push(getModifiedScrollbarStyle(theme)); |
| 180 | } |
| 181 | if (theme.selectionColor) { |
| 182 | lines.push(getModifiedSelectionStyle(theme)); |
| 183 | } |
| 184 | if (isLayerRuleSupported) { |
| 185 | lines.unshift('@layer {'); |
| 186 | lines.push('}'); |
| 187 | } |
| 188 | return lines.join('\n'); |
| 189 | } |
| 190 |
no test coverage detected