(config: Theme, url: string, isTopFrame: boolean, fixes: string, index: SiteFixesIndex)
| 6 | import type {SiteFixesIndex} from './utils/parse'; |
| 7 | |
| 8 | export function createSVGFilterStylesheet(config: Theme, url: string, isTopFrame: boolean, fixes: string, index: SiteFixesIndex): string { |
| 9 | let filterValue: string; |
| 10 | let reverseFilterValue: string; |
| 11 | if (isFirefox) { |
| 12 | filterValue = getEmbeddedSVGFilterValue(getSVGFilterMatrixValue(config)); |
| 13 | reverseFilterValue = getEmbeddedSVGFilterValue(getSVGReverseFilterMatrixValue()); |
| 14 | } else { |
| 15 | // Chrome fails with "Unsafe attempt to load URL ... Domains, protocols and ports must match. |
| 16 | filterValue = 'url(#dark-reader-filter)'; |
| 17 | reverseFilterValue = 'url(#dark-reader-reverse-filter)'; |
| 18 | } |
| 19 | const filterRoot = isFirefox ? 'body' : 'html'; |
| 20 | return cssFilterStyleSheetTemplate(filterRoot, filterValue, reverseFilterValue, config, url, isTopFrame, fixes, index); |
| 21 | } |
| 22 | |
| 23 | function getEmbeddedSVGFilterValue(matrixValue: string): string { |
| 24 | const id = 'dark-reader-filter'; |
no test coverage detected