Skip to content

Commit

Permalink
Revert "Affect img elements with filters (#6044)" (#8149)
Browse files Browse the repository at this point in the history
This reverts commit 29a9a12.

This is causing by far more issues than I'd anticipated, removing for now and can be merged back in once I'd have a better plan to correctly use those.
  • Loading branch information
Gusted committed Feb 5, 2022
1 parent 1207e4a commit 13eeb18
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/inject/dynamic-theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {removeNode, watchForNodePosition, iterateShadowHosts, isDOMReady, remove
import {logInfo, logWarn} from '../../utils/log';
import {throttle} from '../../utils/throttle';
import {clamp} from '../../utils/math';
import {FilterMode, getCSSFilterValue} from '../../generators/css-filter';
import {getCSSFilterValue} from '../../generators/css-filter';
import {modifyBackgroundColor, modifyColor, modifyForegroundColor} from '../../generators/modify-colors';
import {createTextStyle} from '../../generators/text-style';
import type {FilterConfig, DynamicThemeFix} from '../../definitions';
Expand Down Expand Up @@ -86,27 +86,18 @@ function createStaticStyleOverrides() {
setupNodePositionWatcher(textStyle, 'text');

const invertStyle = createOrUpdateStyle('darkreader--invert');
let invertStyleContent = '';
if (fixes && Array.isArray(fixes.invert) && fixes.invert.length > 0) {
invertStyleContent += [
invertStyle.textContent = [
`${fixes.invert.join(', ')} {`,
` filter: ${getCSSFilterValue({
...filter,
contrast: filter.mode === 0 ? filter.contrast : clamp(filter.contrast - 10, 0, 100),
})} !important;`,
'}',
'',
].join('\n');
} else {
invertStyle.textContent = '';
}
const imageFilter = getCSSFilterValue({
...filter,
// Disables the invert() hue-rotate()
mode: FilterMode.light
});
if (imageFilter) {
invertStyleContent += `img { filter: ${imageFilter} !important;\n`;
}
invertStyle.textContent = invertStyleContent;
document.head.insertBefore(invertStyle, textStyle.nextSibling);
setupNodePositionWatcher(invertStyle, 'invert');

Expand Down

0 comments on commit 13eeb18

Please sign in to comment.