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.