https://hefaz-iran.ir/wp-content/themes/someh/assets/someh-darkmode/wcpt-tel-guard.js?ver=1791140394
1 2/*! ADF â WCPT Tel Guard (v1.4.43) 3 * Ensures phone links inside late-loaded WCPT banners become readable in dark mode, 4 * and revert cleanly to light mode. Targets .wcpt-eta, .wcpt-badge, [class^="wcpt-trust"], .tmcpt-phone 5 */ 6(function(){ 7 "use strict"; 8 9 function isDark(){ 10 try{ 11 var de = document.documentElement, b = document.body; 12 return !!( 13 de && ( 14 de.classList.contains("ai-dark") || 15 de.classList.contains("ai-dark-by-clock") || 16 de.classList.contains("dark") || 17 de.classList.contains("dark-mode") || 18 de.classList.contains("wp-dark-mode-active") || 19 (de.getAttribute("data-theme")==="dark") 20 ) || 21 (b && b.classList && b.classList.contains("dark")) 22 ); 23 }catch(e){ return false; } 24 } 25 26 var SCOPE = '.wcpt-eta, .wcpt-badge, [class^="wcpt-trust"], [class*=" wcpt-trust"]'; 27 var TEL = 'a[href^="tel:"], .tmcpt-phone'; 28 29 function each(list, fn){ 30 if (!list) return; 31 for (var i=0;i<list.length;i++){ fn(list[i], i); } 32 } 33 34 function cleanInlineColor(el){ 35 try{ 36 var st = el.getAttribute("style"); 37 if (!st) return; 38 // Save once 39 if (!el.hasAttribute("data-adf-prev-color")){ 40 var m = /(^|;)\s*color\s*:\s*([^;!]+)!?\s*;?/i.exec(st); 41 el.setAttribute("data-adf-prev-color", m ? m[2].trim() : ""); 42 } 43 // Remove any inline color declarations to let our CSS win 44 st = st 45 .replace(/(^|;)\s*color\s*:\s*[^;]+;?/ig, "$1") 46 .replace(/;;+/g, ";") 47 .trim(); 48 if (st === "" || st === ";") el.removeAttribute("style"); else el.setAttribute("style", st); 49 }catch(_){} 50 } 51 52 function restoreInlineColor(el){ 53 try{ 54 var prev = el.getAttribute("data-adf-prev-color"); 55 if (prev != null){ 56 // If we had saved something explicit, restore it; otherwise ensure no leftover color inline from dark pass 57 var st = el.getAttribute("style") || ""; 58 // First remove any color declarations we might have added/cleaned 59 st = st.replace(/(^|;)\s*color\s*:\s*[^;]+;?/ig, "$1").replace(/;;+/g, ";").trim(); 60 if (prev){ 61 st = (st ? (st.replace(/;$/,"")+"; ") : "") + "color: "+prev+";"; 62 el.setAttribute("style", st); 63 }else{ 64 if (st === "" || st === ";") el.removeAttribute("style"); else el.setAttribute("style", st); 65 } 66 el.removeAttribute("data-adf-prev-color"); 67 } 68 el.classList.remove("adf-wcpt-dark-tel"); 69 }catch(_){} 70 } 71 72 function apply(root){ 73 try{ 74 var scopes = root ? (root.matches && root.matches(SCOPE) ? [root] : (root.querySelectorAll ? root.querySelectorAll(SCOPE) : [])) : document.querySelectorAll(SCOPE); 75 each(scopes, function(sc){ 76 var tels = sc.querySelectorAll(TEL); 77 each(tels, function(a){ 78 if (isDark()){ 79 cleanInlineColor(a); 80 a.classList.add("adf-wcpt-dark-tel"); 81 }else{ 82 restoreInlineColor(a); 83 } 84 }); 85 }); 86 }catch(_){} 87 } 88 89 function onToggle(){ setTimeout(function(){ apply(document); }, 20); } 90 91 function ready(fn){ 92 if (document.readyState === "loading"){ 93 document.addEventListener("DOMContentLoaded", fn, { once:true }); 94 } else { fn(); } 95 } 96 97 ready(function(){ 98 apply(document); 99 // banners often appear with delay; observe DOM 100 try{ 101 new MutationObserver(function(muts){ 102 for (var i=0;i<muts.length;i++){ 103 var nodes = muts[i].addedNodes || []; 104 for (var j=0;j<nodes.length;j++){ 105 var el = nodes[j]; 106 if (el && el.nodeType === 1){ 107 if (el.matches && (el.matches(SCOPE) || el.matches(TEL))) apply(el); 108 var any = el.querySelectorAll ? el.querySelectorAll(SCOPE+", "+TEL) : null; 109 if (any && any.length) apply(el); 110 } 111 } 112 } 113 }).observe(document.body, {childList:true, subtree:true}); 114 }catch(_){} 115 116 window.addEventListener("wp-dark-mode-toggled", onToggle, false); 117 try{ 118 var de = document.documentElement, last = de.className; 119 new MutationObserver(function(){ 120 if (last !== de.className){ 121 last = de.className;
122 onToggle(); 123 } 124 }).observe(de, { attributes:true, attributeFilter:["class"] }); 125 }catch(_){} 126 }); 127})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.