PageSourceSearch

https://zuomod.com/wp-content/uploads/custom-css-js/31548.js?v=2778

js zuomod.com collected 2026-09-25 18:42:33 UTC 7,588 bytes, 237 lines download raw bytes

1/******* Do not edit this file *******
2Simple Custom CSS and JS - by Silkypress.com
3Saved: Aug 26 2026 | 11:09:07 */
4(function () {
5    'use strict';
6    const MENU_ITEM_ID = 'menu-item-30290';
7    const PROTECTED_PATHS = [
8        '/collection/markdown/',
9        '/collection/fd79000f-26e8-480b-8a74-9ebf5a6fbe10/'
10    ];
11    const REDIRECT_URL = '/404';
12
13    const QUERY_PARAM = 'search'; // change to whatever param name you want to gate on
14
15    function safeParse(value) {
16        try {
17            return typeof value === 'string' ? JSON.parse(value) : value;
18        } catch {
19            return null;
20        }
21    }
22
23    function isLoggedIn() {
24        try {
25            const persistRoot = safeParse(localStorage.getItem('persist:root'));
26            if (persistRoot) {
27                const persistedUserData = safeParse(persistRoot.persistedUserData);
28                if (persistedUserData?.auth_access_token) {
29                    return true;
30                }
31                const auth = safeParse(persistRoot.auth);
32                if (auth?.auth_access_token) {
33                    return true;
34                }
35            }
36            const userDetails = safeParse(localStorage.getItem('UserDetails'));
37            if (
38                userDetails?.auth_access_token ||
39                userDetails?.accessToken ||
40                userDetails?.access_token
41            ) {
42                return true;
43            }
44            return !!(
45                localStorage.getItem('auth_token') ||
46                localStorage.getItem('authToken')
47            );
48        } catch (err) {
49            console.error('Login check failed:', err);
50            return false;
51        }
52    }
53
54    function normalizePath(path) {
55        try {
56            const url = new URL(path, window.location.origin);
57            let p = url.pathname;
58            if (!p.endsWith('/')) p += '/';
59            return p;
60        } catch {
61            return path;
62        }
63    }
64
65    function isProtectedPath(path) {
66        return PROTECTED_PATHS.includes(normalizePath(path));
67    }
68
69    function isProtectedUrl(href) {
70        if (!href) return false;
71        return isProtectedPath(href);
72    }
73
74    // Runs IMMEDIATELY — no DOMContentLoaded wait.
75    if (
76        !document.body?.classList.contains('elementor-editor-active') &&
77        isProtectedPath(window.location.pathname) &&
78        !isLoggedIn()
79    ) {
80        window.location.replace(REDIRECT_URL);
81        return;
82    }
83
84    function updateMenuItemVisibility() {
85        const item = document.getElementById(MENU_ITEM_ID);
86        if (!item) {
87            return false;
88        }
89        if (document.body.classList.contains('elementor-editor-active')) {
90            item.style.display = '';
91            return true;
92        }
93        item.style.setProperty('display', isLoggedIn() ? '' : 'none', 'important');
94        return true;
95    }
96
97    function updateTradeAccountVisibility() {
98        const tradeAccountElements = document.querySelectorAll('.trade_account');
99    
100        const customTempElements = document.querySelectorAll(
101            '.custom_temp[href="/signup/new/"], .custom_temp[href="/signup/existing/"]'
102        );
103    
104        const elements = [
105            ...tradeAccountElements,
106            ...customTempElements
107        ];
108    
109        elements.forEach((element) => {
110            if (document.body.classList.contains('elementor-editor-active')) {
111                element.style.display = '';
112                return;
113            }
114    
115            element.style.setProperty(
116                'display',
117                isLoggedIn() ? 'none' : '',
118                'important'
119            );
120        });
121    }
122
123    function attachClickGuard() {
124        const item = document.getElementById(MENU_ITEM_ID);
125        if (!item || item.dataset.wizGuardAttached) {
126            return false;
127        }
128        const link = item.tagName === 'A' ? item : item.querySelector('a');
129        if (!link || !isProtectedUrl(link.getAttribute('href'))) {
130            return false;
131        }
132        link.addEventListener('click', function (e) {
133            if (document.body.classList.contains('elementor-editor-active')) {
134                return;
135            }
136            if (!isLoggedIn()) {
137                e.preventDefault();
138                e.stopImmediatePropagation();
139                window.location.href = REDIRECT_URL;
140            }
141        }, true);
142        item.dataset.wizGuardAttached = 'true';
143        return true;
144    }
145
146    function hasQueryParam() {
147        try {
148            return new URLSearchParams(window.location.search).has(QUERY_PARAM);
149        } catch {
150            return false;
151        }
152    }
153
154    const SEARCH_ACTIVE_CLASS = 'wiz-search-active';
155
156    function updateHiddenContainers() {
157        const show = hasQueryParam();
158        document.documentElement.classList.toggle(SEARCH_ACTIVE_CLASS, show);
159    }
160
161    // Patch pushState/replaceState so URL changes made by client-side
162    // routers/search widgets (without a full page reload) are detected too.
163    function patchHistoryForUrlChanges() {
164        if (history.__wizPatched) {
165            return;
166        }
167        history.__wizPatched = true;
168
169        const fire = () => window.dispatchEvent(new Event('wiz_url_changed'));
170
171        const origPushState = history.pushState;
172        history.pushState = function (...args) {
173            const result = origPushState.apply(this, args);
174            fire();
175            return result;
176        };
177
178        const origReplaceState = history.replaceState;
179        history.replaceState = function (...args) {
180            const result = origReplaceState.apply(this, args);
181            fire();
182            return result;
183        };
184    }
185
186    function init() {
187        patchHistoryForUrlChanges();
188
189        updateMenuItemVisibility();
190        updateTradeAccountVisibility();
191        attachClickGuard();
192        updateHiddenContainers();
193
194        window.addEventListener('storage', updateMenuItemVisibility);
195        window.addEventListener('wiz_auth_changed', updateMenuItemVisibility);
196        window.addEventListener('wiz_url_changed', updateHiddenContainers);
197
198        window.addEventListener('popstate', function () {
199            if (isProtectedPath(window.location.pathname) && !isLoggedIn()) {
200                window.location.replace(REDIRECT_URL);
201                return;
202            }
203            updateMenuItemVisibility();
204            updateHiddenContainers();
205        });
206
207        if (document.getElementById(MENU_ITEM_ID)) {
208            return;
209        }
210
211        let debounceTimer;
212        const observer = new MutationObserver(() => {
213            clearTimeout(debounceTimer);
214            debounceTimer = setTimeout(() => {
215                const found = updateMenuItemVisibility();
216                updateTradeAccountVisibility();
217                attachClickGuard();
218                updateHiddenContainers();
219                if (found) {
220                    observer.disconnect();
221                }
222            }, 50);
223        });
224
225        observer.observe(document.body, {
226            childList: true,
227            subtree: true
228        });
229        setTimeout(() => observer.disconnect(), 10000);
230    }
231
232    if (document.readyState === 'loading') {
233        document.addEventListener('DOMContentLoaded', init);
234    } else {
235        init();
236    }
237})();

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.