PageSourceSearch

https://www.ogorod.ru/daily/_js/dp.js?v=1790347708

js ogorod.ru collected 2026-09-25 14:57:45 UTC 4,379 bytes, 121 lines download raw bytes

1// Функция для получения Open Graph разметки
2// async 
3async function fetchOpenGraphData(url) {
4    const response = await fetch(url); // await
5    const text = await response.text();
6    const parser = new DOMParser();
7    const doc = parser.parseFromString(text, 'text/html');
8    const metaTags = doc.querySelectorAll('meta[property^="og:"]');
9    const ogData = {};
10
11    metaTags.forEach(tag => {
12        const property = tag.getAttribute('property');
13        const content = tag.getAttribute('content');
14        ogData[property] = content;
15    });
16    return ogData;
17}
18
19
20// Функция для замены href на Open Graph разметку
21// async
22async function replaceHrefWithOpenGraph(ul) { // ulElements
23    //const ulElements = document.querySelectorAll('ul.hyper');
24    console.log('111222');
25//    for (let ul of ulElements) {
26
27        console.log('111333');
28
29        const liElements = ul.querySelectorAll('li');
30        for (let li of liElements) {
31
32            console.log(li.textContent);
33//          allText += li\.textContent + ' '; // Добавляем текст из li в переменную
34
35//          const url = li.textContent;
36//          const link = document.createElement('a');
37
38//          link.href = url;
39//          li.appendChild(link);
40
41//          li.textContent = '';
42//          li.replaceChild(link);
43
44
45            const text = li.textContent; // Получаем текст из li
46//            const url = `${encodeURIComponent(text)}`; // Создаем URL на основе текста
47            const url = li.textContent;
48            console.log(url);
49
50
51            // Создаем элемент a
52            const link = document.createElement('a');
53            link.href = url;
54//            link.textContent = text;
55
56            // Очищаем текст внутри li и добавляем ссылку
57            li.textContent = '';
58            while (li.firstChild) {
59                li.removeChild(li.firstChild);
60            }
61            li.appendChild(link);
62
63            const ogData = await fetchOpenGraphData(url); // await
64
65            for (let property in ogData) {
66                console.log(`${property}: ${ogData[property]}`);
67            }
68
69
70            // Создаем элемент для отображения Open Graph разметки
71            const leftDiv = document.createElement('div');
72                    leftDiv.classList.add('left');
73                const figure = document.createElement('figure');
74                    leftDiv.appendChild(figure);
75                const img = document.createElement('img');
76                    img.src = ogData['og:image'];
77                    figure.appendChild(img);
78            link.appendChild(leftDiv); // parentNode
79            const rightDiv = document.createElement('div');
80                    rightDiv.classList.add('right');
81                const h6 = document.createElement('div');
82                    h6.classList.add('h6');
83                    rightDiv.appendChild(h6);
84                const p1 = document.createElement('p');
85                    p1.textContent = ogData['og:title'];
86                    h6.appendChild(p1);
87                const p2 = document.createElement('span');
88                    p2.textContent = ogData['og:description'];
89                    rightDiv.appendChild(p2);
90            link.appendChild(rightDiv); // parentNode
91
92            link.parentNode.parentNode.classList.add('op-related-articles');
93
94    };
95//    }; // ulElements.forEach
96  }
97
98
99console.log('111');
100//window.onload = replaceHrefWithOpenGraph;
101
102
103function checkScroll() {
104    const uls = document.querySelectorAll('ul.hyper'); 
105    const screenHeight = window.innerHeight;
106//    console.log('444');
107
108    uls.forEach(ul => {
109        const targetPosition = ul.getBoundingClientRect().top;
110
111        // Проверяем, находится ли блок div за два экрана до видимой области
112        if (targetPosition <= screenHeight * 4) {
113            replaceHrefWithOpenGraph(ul);
114            // Удаляем класс, чтобы функция не вызывалась повторно для этого блока
115            ul.classList.remove('hyper');
116            ul.classList.add('hyper-done');
117        }
118    });
119}
120
121  window.addEventListener('scroll', checkScroll);

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.