MCPcopy
hub / github.com/darkreader/darkreader / interceptOldScript

Function interceptOldScript

src/inject/dynamic-theme/index.ts:589–607  ·  view source on GitHub ↗
({success, failure}: {success: () => void; failure: () => void})

Source from the content-addressed store, hash-verified

587let interceptorAttempts = 2;
588
589function interceptOldScript({success, failure}: {success: () => void; failure: () => void}) {
590 if (--interceptorAttempts <= 0) {
591 failure();
592 return;
593 }
594
595 const oldMeta = document.head.querySelector('meta[name="darkreader"]') as HTMLMetaElement | null;
596 if (!oldMeta || oldMeta.content === INSTANCE_ID) {
597 return;
598 }
599
600 const lock = document.createElement('meta');
601 lock.name = 'darkreader-lock';
602 document.head.append(lock);
603 queueMicrotask(() => {
604 lock.remove();
605 success();
606 });
607}
608
609function disableConflictingPlugins() {
610 if (document.documentElement.hasAttribute('data-wp-dark-mode-preset')) {

Callers 1

readyFunction · 0.85

Calls 3

failureFunction · 0.85
successFunction · 0.85
removeMethod · 0.65

Tested by

no test coverage detected