| 587 | let interceptorAttempts = 2; |
| 588 | |
| 589 | function 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 | |
| 609 | function disableConflictingPlugins() { |
| 610 | if (document.documentElement.hasAttribute('data-wp-dark-mode-preset')) { |