|
| 1 | +(function () { |
| 2 | + "use strict"; |
| 3 | + |
| 4 | + var ICON_MARKUP = |
| 5 | + '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align:-3px;margin-right:6px;flex-shrink:0">' + |
| 6 | + '<path d="M15 2.5H12C7.52166 2.5 5.28249 2.5 3.89124 3.89124C2.5 5.28249 2.5 7.52166 2.5 12C2.5 16.4783 2.5 18.7175 3.89124 20.1088C5.28249 21.5 7.52166 21.5 12 21.5C16.4783 21.5 18.7175 21.5 20.1088 20.1088C21.5 18.7175 21.5 16.4783 21.5 12V10" stroke="#22C55E" stroke-width="2" stroke-linecap="round"/>' + |
| 7 | + '<path d="M8.5 10L12 13.5L21.0002 3.5" stroke="#22C55E" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>' + |
| 8 | + "</svg>"; |
| 9 | + |
| 10 | + function createIcon() { |
| 11 | + var span = document.createElement("span"); |
| 12 | + span.innerHTML = ICON_MARKUP; |
| 13 | + return span.firstChild; |
| 14 | + } |
| 15 | + |
| 16 | + function fix() { |
| 17 | + var walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null); |
| 18 | + var matches = []; |
| 19 | + var node; |
| 20 | + while ((node = walker.nextNode())) { |
| 21 | + if (node.nodeValue.trim() === "✅") matches.push(node); |
| 22 | + } |
| 23 | + matches.forEach(function (textNode) { |
| 24 | + textNode.parentNode.replaceChild(createIcon(), textNode); |
| 25 | + }); |
| 26 | + } |
| 27 | + |
| 28 | + fix(); |
| 29 | + document.addEventListener("DOMContentLoaded", fix); |
| 30 | + window.addEventListener("load", fix); |
| 31 | + |
| 32 | + // The Sapper bundle re-renders this section on hydration and on each |
| 33 | + // data poll, reinstating the emoji text node — watch for that and |
| 34 | + // swap it back to the SVG. This script runs from a <script> tag in |
| 35 | + // <nav>, before <main> exists, so observe document.body (already |
| 36 | + // present when the tag executes) rather than a more specific |
| 37 | + // container that isn't in the DOM yet. |
| 38 | + if (window.MutationObserver) { |
| 39 | + new MutationObserver(fix).observe(document.body, { |
| 40 | + childList: true, |
| 41 | + subtree: true, |
| 42 | + characterData: true, |
| 43 | + }); |
| 44 | + } |
| 45 | +})(); |
0 commit comments