MCPcopy
hub / github.com/darkreader/darkreader / removeDynamicTheme

Function removeDynamicTheme

src/inject/dynamic-theme/index.ts:887–928  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

885}
886
887export function removeDynamicTheme(): void {
888 document.documentElement.removeAttribute(`data-darkreader-mode`);
889 document.documentElement.removeAttribute(`data-darkreader-scheme`);
890 cleanDynamicThemeCache();
891 removeNode(document.querySelector('.darkreader--fallback'));
892 if (document.head) {
893 const selectors = [
894 '.darkreader--user-agent',
895 '.darkreader--text',
896 '.darkreader--invert',
897 '.darkreader--inline',
898 '.darkreader--override',
899 '.darkreader--variables',
900 '.darkreader--root-vars',
901 'meta[name="darkreader"]',
902 ];
903
904 restoreMetaThemeColor();
905 selectors.forEach((selector) => removeNode(document.head.querySelector(selector)));
906 staticStyleMap = new WeakMap();
907 removeProxy();
908 }
909 shadowRootsWithOverrides.forEach((root) => {
910 removeNode(root.querySelector('.darkreader--inline'));
911 removeNode(root.querySelector('.darkreader--override'));
912 });
913 shadowRootsWithOverrides.clear();
914 forEach(styleManagers.keys(), (el) => removeManager(el));
915 loadingStyles.clear();
916 cleanLoadingLinks();
917 forEach(document.querySelectorAll('.darkreader'), removeNode);
918 removeStyleContainer();
919
920 adoptedStyleManagers.forEach((manager) => manager.destroy());
921 adoptedStyleManagers.splice(0);
922
923 metaObserver && metaObserver.disconnect();
924 scheduleInversionStyleUpdate.cancel();
925
926 cleaners.forEach((clean) => clean());
927 cleaners.splice(0);
928}
929
930export function cleanDynamicThemeCache(): void {
931 variablesStore.clear();

Callers 14

responseHandlerFunction · 0.90
onMessageFunction · 0.90
disableFunction · 0.90
color.tests.tsFile · 0.90
fixes.tests.tsFile · 0.90
variables.tests.tsFile · 0.90

Calls 12

removeNodeFunction · 0.90
restoreMetaThemeColorFunction · 0.90
forEachFunction · 0.90
cleanLoadingLinksFunction · 0.90
removeStyleContainerFunction · 0.90
cleanDynamicThemeCacheFunction · 0.85
removeProxyFunction · 0.85
removeManagerFunction · 0.85
cleanFunction · 0.85
disconnectMethod · 0.80
destroyMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected