PageSourceSearch

https://hefaz-iran.ir/wp-content/themes/someh/assets/someh-darkmode/mobile-critical-inject.js?ver=1791140394

js hefaz-iran.ir collected 2026-10-09 04:41:13 UTC 18,388 bytes, 345 lines download raw bytes

1/*! v1.4.19 mobile-critical-inject: ensure last-in-head rules with !important (Ahan Sazeh) */
2(function(){
3  var CSS = [
4    '@media (max-width:900px){',
5    'html[class*="dark"] body .phone-bar,html.wp-dark-mode-active body .phone-bar,html[class*="dark"] body .DO_NOT_TOUCH_TOPNAV,html.wp-dark-mode-active body .DO_NOT_TOUCH_TOPNAV,html[class*="dark"] body .DO_NOT_TOUCH_TOPNAV,html.wp-dark-mode-active body .DO_NOT_TOUCH_TOPNAV,html[class*="dark"] body .DO_NOT_TOUCH_HEADERNAV,html.wp-dark-mode-active body .DO_NOT_TOUCH_HEADERNAV{background:#141618 !important;color:#e9eef3 !important;border-color:#2a2d31 !important;}',
6    'html[class*="dark"] body .phone-bar a[href^="tel:"],html.wp-dark-mode-active body .phone-bar a[href^="tel:"],html[class*="dark"] body .DO_NOT_TOUCH_TOPNAV a[href^="tel:"],html.wp-dark-mode-active body .DO_NOT_TOUCH_TOPNAV a[href^="tel:"],html[class*="dark"] body .DO_NOT_TOUCH_TOPNAV a[href^="tel:"],html.wp-dark-mode-active body .DO_NOT_TOUCH_TOPNAV a[href^="tel:"],html[class*="dark"] body .DO_NOT_TOUCH_HEADERNAV a[href^="tel:"],html.wp-dark-mode-active body .DO_NOT_TOUCH_HEADERNAV a[href^="tel:"]{color:#39dbc4 !important;font-weight:800 !important;text-decoration:none !important;}',
7    'html[class*="dark"] body .entry-content table thead,html.wp-dark-mode-active body .entry-content table thead,html[class*="dark"] body .entry-content .wp-block-table thead,html.wp-dark-mode-active body .entry-content .wp-block-table thead,html[class*="dark"] body .entry-content .tablepress thead,html.wp-dark-mode-active body .entry-content .tablepress thead,html[class*="dark"] body .entry-content .dataTable thead,html.wp-dark-mode-active body .entry-content .dataTable thead,html[class*="dark"] body .dataTables_scrollHead thead{display:table-header-group !important;visibility:visible !important;height:auto !important;opacity:1 !important;}',
8    'html[class*="dark"] body .entry-content table thead tr{display:table-row !important;}',
9    'html[class*="dark"] body .entry-content table thead th{display:table-cell !important;position:sticky !important;top:0 !important;z-index:9 !important;background:#1a1f24 !important;color:#e9eef3 !important;border-color:rgba(255,255,255,.18) !important;text-shadow:none !important;}',
10    '}'
11  ].join('');
12
13  // --- v1.4.27 helpers: dark detection + cleanup for day mode ---
14  function __adf_isDark(){
15    var h=document.documentElement, b=document.body||h;
16    return ( (h.className && /dark|wp-dark-mode-active|is-dark-mode/.test(h.className)) ||
17             (b.className && /dark|wp-dark-mode-active|is-dark-mode/.test(b.className)) ||
18             h.getAttribute('data-theme')==='dark' || b.getAttribute('data-theme')==='dark' );
19  }
20
21  function __adf_cleanupLightMode(){
22    // فقط در حالت روز پاک‌سازی کن
23    if (__adf_isDark()) return;
24    try{
25      // هدرها + headerهای ردیف
26      var selHeads = [
27        '.entry-content table thead th',
28        '.dataTables_scrollHead table thead th',
29        'table.tablepress thead th',
30        '.wp-block-table thead th',
31        'table thead th',
32        'table tbody th',
33        '.wp-block-table tbody th',
34        '.tablepress tbody th',
35        '.dataTable tbody th'
36      ].join(',');
37      document.querySelectorAll(selHeads).forEach(function(th){
38        [
39          'background',
40          'color',
41          'border-color',
42          'mix-blend-mode',
43          'filter',
44          'text-shadow',
45          'position',
46          'top',
47          'z-index',
48          'font-weight'
49        ].forEach(function(p){
50          th.style.removeProperty(p);
51        });
52      });
53
54      // ستون اول (td و column-1)
55      var selFirst = [
56        'table tr > td:first-child',
57        '.wp-block-table .has-fixed-layout tr > td:first-child',
58        '.tablepress .column-1'
59      ].join(',');
60      document.querySelectorAll(selFirst).forEach(function(td){
61        ['background','color','border-color','font-weight'].forEach(function(p){
62          td.style.removeProperty(p);
63        });
64      });
65    }catch(e){}
66  }
67
68  function ensureStyle(){
69    // اینجا دیگه چک دارک نمی‌کنیم؛ این کار در run انجام می‌شود
70    if (window.innerWidth > 900) return;
71    var id = 'ahan-mobile-dark-critical';
72    var el = document.getElementById(id);
73    if (!el){
74      el = document.createElement('style');
75      el.type = 'text/css';
76      el.id = id;
77      document.head.appendChild(el);
78    } else {
79      // move to end to win cascade
80      document.head.appendChild(el);
81    }
82    if (el.styleSheet){ el.styleSheet.cssText = CSS; }
83    else { el.textContent = CSS; }
84  }
85
86  function isDark(){
87    var h = document.documentElement, b = document.body||h;
88    return h.classList.contains('wp-dark-mode-active') ||
89           b.hasAttribute('data-wp-dark-mode-active') ||
90           h.classList.contains('dark') || b.classList.contains('dark') ||
91           h.classList.contains('dark-mode') || b.classList.contains('dark-mode') ||
92           h.classList.contains('is-dark-mode') || b.classList.contains('is-dark-mode') ||
93           h.classList.contains('ai-dark') || b.classList.contains('ai-dark') ||
94           h.getAttribute('data-theme')==='dark' || b.getAttribute('data-theme')==='dark';
95  }
96
97  function run(){
98    // اگر دارک نیستیم، فقط cleanup انجام بده و برگرد
99    if (!isDark()){
100      __adf_cleanupLightMode();
101      return;
102    }
103
104    ensureStyle();
105
106    // additionally enforce computed style on <thead> فقط در حالت دارک
107    try{
108      document.querySelectorAll('.entry-content table, table').forEach(function(tbl){
109        var thead = tbl.querySelector('thead');
110        if (!thead) return;
111        var cs = getComputedStyle(thead);
112        if (cs.display !== 'table-header-group' || thead.offsetHeight < 1){
113          thead.style.setProperty('display','table-header-group','important');
114          thead.style.removeProperty('visibility');
115          thead.removeAttribute('aria-hidden');
116          thead.querySelectorAll('tr').forEach(function(tr){
117            tr.style.setProperty('display','table-row','important');
118            tr.style.removeProperty('visibility');
119          });
120          thead.querySelectorAll('th').forEach(function(th){
121            th.style.setProperty('display','table-cell','important');
122            th.style.setProperty('position','sticky','important');
123            th.style.setProperty('top','0','important');
124            th.style.setProperty('z-index','9');
125            th.style.setProperty('background','#1a1f24','important');
126            th.style.setProperty('color','#e9eef3','important');
127          });
128        }
129      });
130    }catch(e){}
131  }
132
133  function ready(fn){
134    if (document.readyState === 'loading'){
135      document.addEventListener('DOMContentLoaded', fn, { once:true });
136    } else { fn(); }
137  }
138
139  ready(run);
140  window.addEventListener('resize', run, false);
141  window.addEventListener('wp-dark-mode-toggled', function(){ setTimeout(run, 30); }, false);
142  try{
143    var target = document.documentElement, last = target.className;
144    new MutationObserver(function(){
145      if (last !== target.className){ last = target.className; run(); }
146    }).observe(target, { attributes:true, attributeFilter:['class'] });
147  }catch(e){}
148})();
149
150
151/* v1.4.20 runtime hardening */
152(function(){
153  function forcePhone(){
154    var sels = [
155      '.DO_NOT_TOUCH_TOPNAV a[href^="tel:"]','.DO_NOT_TOUCH_TOPNAV a[href^="tel:"]','.DO_NOT_TOUCH_HEADERNAV a[href^="tel:"]','.phone-bar a[href^="tel:"]'
156    ];
157    try{
158      document.querySelectorAll(sels.join(',')).forEach(function(a){
159        a.style.setProperty('color','#39dbc4','important');
160        a.style.setProperty('font-weight','800','important');
161        a.style.setProperty('text-decoration','none','important');
162      });
163      var bars = document.querySelectorAll('.phone-bar');
164      bars.forEach(function(b){
165        b.style.setProperty('background','#141618','important');
166        b.style.setProperty('color','#e9eef3','important');
167        b.style.setProperty('border-color','#2a2d31','important');
168      });
169    }catch(e){}
170  }
171
172  // چک حالت دارک برای این IIFE
173  function isDark(){
174    var h=document.documentElement,b=document.body||h;
175    return (h.className && /dark|wp-dark-mode-active|is-dark-mode/.test(h.className)) ||
176           (b.className && /dark|wp-dark-mode-active|is-dark-mode/.test(b.className)) ||
177           h.getAttribute('data-theme')==='dark' || b.getAttribute('data-theme')==='dark';
178  }
179
180  function forceRowHeaders(){
181    // فقط در حالت شب
182    if (!isDark()) return;
183    try{
184      var rowSel = [
185        'table tbody th',
186        '.wp-block-table tbody th','.tablepress tbody th','.dataTable tbody th',
187        'table tr > th[scope="row"]','table tr > td[scope="row"]',
188        'html[class*="dark"] body table tr > td:first-child',
189        'html[class*="dark"] body .tablepress .column-1',
190        'html[class*="dark"] body .wp-block-table .has-fixed-layout tr > td:first-child'
191      ].join(',');
192      document.querySelectorAll(rowSel).forEach(function(el){
193        el.style.setProperty('background','#101317','important');
194        el.style.setProperty('color','#e9eef3','important');
195        el.style.setProperty('font-weight','700','important');
196        el.style.setProperty('border-color','rgba(255,255,255,0.12)','important');
197      });
198      // responsive labels
199      document.querySelectorAll('.dataTables_wrapper .dtr-title,.stacktable .st-key,.st-key').forEach(function(el){
200        el.style.setProperty('color','#c9d4de','important');
201        el.style.setProperty('font-weight','700','important');
202      });
203    }catch(e){}
204  }
205
206  function runForce(){
207    forcePhone();      // رفتار قبلی برای تلفن‌ها حفظ شده
208    forceRowHeaders(); // ولی رنگ‌دهی ستون اول فقط در حالت دارک
209  }
210
211  document.addEventListener('DOMContentLoaded', runForce, {once:true});
212  window.addEventListener('resize', function(){ setTimeout(runForce, 30); }, false);
213  window.addEventListener('wp-dark-mode-toggled', function(){ setTimeout(runForce, 30); }, false);
214  try{
215    var target = document.documentElement, last = target.className;
216    new MutationObserver(function(){
217      if (last !== target.className){ last = target.className; runForce(); }
218    }).observe(target, { attributes:true, attributeFilter:['class'] });
219  }catch(e){}
220})();
221
222
223/* v1.4.22 light table theme */
224(function(){
225  function injectLightTable(){
226    if (window.innerWidth > 900) return;
227    var h = document.documentElement, b = document.body||h;
228    var isDark = h.className.match(/dark|wp-dark-mode-active|is-dark-mode/) ||
229                 b.className && b.className.match(/dark|wp-dark-mode-active|is-dark-mode/) ||
230                 h.getAttribute('data-theme')==='dark' || b.getAttribute('data-theme')==='dark';
231    if (!isDark) return;
232    var CSS = [
233      '@media (max-width:900px){',
234      'html[class*="dark"] body .entry-content table,html[class*="dark"] body .entry-content .wp-block-table table,html[class*="dark"] body .wp-block-table,html[class*="dark"] body .tablepress,html[class*="dark"] body .dataTables_wrapper table,html[class*="dark"] body .dataTable{background:#fff !important;color:#111 !important;border-color:#e5e7eb !important;}',
235      'html[class*="dark"] body .entry-content table th,html[class*="dark"] body .entry-content table td,html[class*="dark"] body .wp-block-table th,html[class*="dark"] body .wp-block-table td,html[class*="dark"] body .tablepress th,html[class*="dark"] body .tablepress td,html[class*="dark"] body .dataTable th,html[class*="dark"] body .dataTable td{background:#fff !important;color:#111 !important;border-color:#e5e7eb !important;text-shadow:none !important;}',
236      'html[class*="dark"] body .entry-content table thead th,html[class*="dark"] body .wp-block-table thead th,html[class*="dark"] body .tablepress thead th,html[class*="dark"] body .dataTable thead th{position:sticky !important;top:0 !important;z-index:9 !important;background:#fff !important;color:#111 !important;border-color:#e5e7eb !important;box-shadow:0 1px 0 rgba(0,0,0,.06);}',
237      'html[class*="dark"] body .entry-content table tbody tr:nth-child(even) td,html[class*="dark"] body .wp-block-table tbody tr:nth-child(even) td,html[class*="dark"] body .tablepress tbody tr:nth-child(even) td,html[class*="dark"] body .dataTable tbody tr:nth-child(even) td{background:#fafafa !important;}',
238      'html[class*="dark"] body table tbody th,html[class*="dark"] body .wp-block-table tbody th,html[class*="dark"] body .tablepress tbody th,html[class*="dark"] body .dataTable tbody th,html[class*="dark"] body table tr > th[scope="row"],html[class*="dark"] body table tr > td[scope="row"],html[class*="dark"] body html[class*="dark"] body table tr > td:first-child,html[class*="dark"] body html[class*="dark"] body .tablepress .column-1,html[class*="dark"] body html[class*="dark"] body .wp-block-table .has-fixed-layout tr > td:first-child{background:#fff !important;color:#111 !important;border-color:#e5e7eb !important;}',
239      'html[class*="dark"] body .entry-content table a,html[class*="dark"] body .wp-block-table a,html[class*="dark"] body .tablepress a,html[class*="dark"] body .dataTable a{color:#0f766e !important;}',
240      '}'
241    ].join('');
242
243    // این نسخه‌ی لوکال از __adf_isDark / __adf_cleanupLightMode فقط برای همین IIFE است
244    function __adf_isDark(){
245      var h=document.documentElement, b=document.body||h;
246      return ( (h.className && /dark|wp-dark-mode-active|is-dark-mode/.test(h.className)) ||
247               (b.className && /dark|wp-dark-mode-active|is-dark-mode/.test(b.className)) ||
248               h.getAttribute('data-theme')==='dark' || b.getAttribute('data-theme')==='dark' );
249    }
250
251    function __adf_cleanupLightMode(){
252      if (__adf_isDark()) return;
253      try{
254        var selHeads = [
255          '.entry-content table thead th',
256          '.dataTables_scrollHead table thead th',
257          'table.tablepress thead th',
258          '.wp-block-table thead th',
259          'table thead th'
260        ].join(',');
261        document.querySelectorAll(selHeads).forEach(function(th){
262          ['background','color','border-color','mix-blend-mode','filter','text-shadow','position','top','z-index'].forEach(function(p){
263            th.style.removeProperty(p);
264          });
265        });
266        var selFirst = [
267          'table tr > td:first-child',
268          '.wp-block-table .has-fixed-layout tr > td:first-child',
269          '.tablepress .column-1'
270        ].join(',');
271        document.querySelectorAll(selFirst).forEach(function(td){
272          ['background','color','border-color','font-weight'].forEach(function(p){
273            td.style.removeProperty(p);
274          });
275        });
276      }catch(e){}
277    }
278
279    var id='ahan-mobile-table-light';
280    var el=document.getElementById(id);
281    if(!el){ el=document.createElement('style'); el.type='text/css'; el.id=id; document.head.appendChild(el); }
282    else { document.head.appendChild(el); }
283    if(el.styleSheet){ el.styleSheet.cssText=CSS; } else { el.textContent=CSS; }
284  }
285  document.addEventListener('DOMContentLoaded', injectLightTable, {once:true});
286  window.addEventListener('resize', function(){ setTimeout(injectLightTable, 30); }, false);
287  window.addEventListener('wp-dark-mode-toggled', function(){ setTimeout(injectLightTable, 30); }, false);
288  try{
289    var target=document.documentElement, last=target.className;
290    new MutationObserver(function(){ if(last!==target.className){ last=target.className; injectLightTable(); } }).observe(target,{attributes:true,attributeFilter:['class']});
291  }catch(e){}
292})();
293
294
295/* v1.4.23 enforce white header cells */
296(function(){
297  function whiteHeaders(){
298    if (window.innerWidth > 900) return;
299    var h = document.documentElement, b = document.body||h;
300    var isDark = h.className.match(/dark|wp-dark-mode-active|is-dark-mode/) ||
301                 (b.className && b.className.match(/dark|wp-dark-mode-active|is-dark-mode/)) ||
302                 h.getAttribute('data-theme')==='dark' || b.getAttribute('data-theme')==='dark';
303    if (!isDark) return;
304    try{
305      var sels = [
306        '.entry-content table thead th',
307        '.dataTables_scrollHead table thead th',
308        'table.tablepress thead th',
309        '.wp-block-table thead th',
310        'table thead th'
311      ].join(',');
312      document.querySelectorAll(sels).forEach(function(th){
313        th.style.setProperty('background','#ffffff','important');
314        th.style.setProperty('background-image','none','important');
315        th.style.setProperty('color','#111111','important');
316        th.style.setProperty('border-color','#e5e7eb','important');
317        th.style.setProperty('text-shadow','none','important');
318      });
319    }catch(e){}
320
321  }
322  document.addEventListener('DOMContentLoaded', whiteHeaders, {once:true});
323  window.addEventListener('resize', function(){ setTimeout(whiteHeaders, 30); }, false);
324  window.addEventListener('wp-dark-mode-toggled', function(){ setTimeout(whiteHeaders, 30); }, false);
325})();
326
327
328/* v1.4.23 .tmcpt-phone purple inline in dark */
329(function(){
330  function purplePhone(){
331    var h=document.documentElement,b=document.body||h;
332    var isDark = h.className.match(/dark|wp-dark-mode-active|is-dark-mode/) ||
333                 (b.className && b.className.match(/dark|wp-dark-mode-active|is-dark-mode/)) ||
334                 h.getAttribute('data-theme')==='dark' || b.getAttribute('data-theme')==='dark';
335    if(!isDark) return;
336    try{
337      document.querySelectorAll('a.tmcpt-phone').forEach(function(a){
338        a.style.setProperty('color','#8b5cf6','important');
339        a.style.setProperty('text-decoration','none','important');
340      });
341    }catch(e){}
342  }
343  document.addEventListener('DOMContentLoaded', purplePhone, {once:true});
344  window.addEventListener('wp-dark-mode-toggled', function(){ setTimeout(purplePhone, 30); }, false);
345})();

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.