PageSourceSearch

https://yboys.net/assets/functions.js

js yboys.net collected 2026-10-09 03:10:59 UTC 5,488 bytes, 159 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function() {
2    const langSelect = document.querySelector('.lang-picker');
3    if (langSelect) {
4        langSelect.addEventListener('change', function() {
5            const selectedValue = this.value;
6            if (selectedValue) {
7                window.location.href = selectedValue;
8            }
9        });
10    }
11    const filterSelects = document.querySelectorAll('.filter-selectbox');
12    filterSelects.forEach(select => {
13        select.addEventListener('change', function() {
14            const selectedValue = this.value;
15            if (selectedValue && selectedValue !== 'any') {
16                // Redirect to the selected value
17                window.location.href = selectedValue;
18            }
19        });
20    });
21});
22
23
24function initLazyLoading() {
25    const lazyImages = document.querySelectorAll('.lazy-image');
26
27    const impressionTracker = {
28        submittedIds: new Set(),
29        pendingIds: new Set(),
30        intervalId: null,
31        niche_id: typeof nid !== 'undefined' && nid ? '|' + nid : '|0',
32
33        init() {
34            if(typeof log_w === 'undefined' || !log_w) {
35                return
36            }
37            setTimeout(() => {
38                this.checkAndSubmitShownImages();
39                this.intervalId = setInterval(() => {
40                    this.checkAndSubmitShownImages();
41                }, 1000);
42            }, 2000);
43        },
44
45        checkAndSubmitShownImages() {
46
47            const shownImages = document.querySelectorAll('.lazy-image.loaded');
48            const newIds = [];
49
50            shownImages.forEach(img => {
51                const videoId = img.dataset.videoId;
52                if (videoId && !this.submittedIds.has(videoId) && !this.pendingIds.has(videoId)) {
53                    newIds.push(videoId);
54                    this.pendingIds.add(videoId);
55                }
56            });
57
58            if (newIds.length > 0) {
59                this.submitToAjax(newIds);
60            }
61        },
62
63        async submitToAjax(videoIds) {
64            try {
65                const dataToSend = videoIds.map(id => id + impressionTracker.niche_id);
66                const body = dataToSend
67                    .map((id, index) => 'i[' + index + ']=' + encodeURIComponent(id))
68                    .join('&');
69
70                const response = await fetch('/l.php', {
71                    method: 'POST',
72                    body: body,
73                    headers: {
74                        'X-Requested-With': 'XMLHttpRequest',
75                        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
76                    }
77                });
78
79                if (response.ok) {
80                    videoIds.forEach(id => {
81                        this.submittedIds.add(id);
82                        this.pendingIds.delete(id);
83                    });
84                } else {
85                    console.error('Failed to submit video IDs:', videoIds);
86                }
87            } catch (error) {
88                console.error('Error submitting video IDs:', error);
89            }
90        },
91
92        destroy() {
93            if (this.intervalId) {
94                clearInterval(this.intervalId);
95            }
96        }
97    };
98
99    impressionTracker.init();
100
101    const imageObserver = new IntersectionObserver((entries, observer) => {
102        entries.forEach(entry => {
103            if (entry.isIntersecting) {
104                const img = entry.target;
105                const placeholder = img.previousElementSibling;
106
107                img.addEventListener('load', () => {
108                    img.classList.add('loaded');
109                    if (placeholder) {
110                        placeholder.style.display = 'none';
111                    }
112                });
113
114                img.addEventListener('error', () => {
115                    if (placeholder) {
116                        placeholder.innerHTML = '<i data-lucide="image-off" class="h-8 w-8 mx-auto mb-2"></i><span class="text-xs">Image not available</span>';
117                        lucide.createIcons();
118                    }
119                });
120
121                img.src = img.dataset.src;
122                observer.unobserve(img);
123            }
124        });
125    });
126
127    lazyImages.forEach(img => imageObserver.observe(img));
128
129    return impressionTracker;
130}
131
132const DO_TRADE = true;
133document.addEventListener("DOMContentLoaded", function () {
134    function Trade() {
135        this.IN = function () {
136            if(!DO_TRADE) return;
137            let refDomainMatch = document.referrer.match(/^https?:\/\/(?:www\.)?([a-z0-9\-.]+)(?:\d+)?/);
138            let refDomain = refDomainMatch && typeof refDomainMatch !== "undefined" && refDomainMatch[1] || "";
139
140            let data = {
141                ref: document.referrer
142            };
143
144            if (!refDomain || !document.domain || document.domain.indexOf(refDomain) === -1) {
145                data.loc = document.location.toString();
146                fetch("/ain.php", {
147                    method: "POST",
148                    headers: {
149                        "Content-Type": "application/x-www-form-urlencoded"
150                    },
151                    body: new URLSearchParams(data),
152                });
153            }
154        };
155    }
156
157    window.trade = new Trade();
158    window.trade.IN();
159});

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.