Загрузка данных


(function() {
    // 1. Собираем все уникальные ссылки со страницы
    const links = Array.from(document.querySelectorAll('a'))
                       .map(a => a.href)
                       .filter((href, index, self) => href && self.indexOf(href) === index);

    if (links.length === 0) {
        alert('Ссылок на странице не найдено!');
        return;
    }

    // 2. Создаем блок для нашего окна
    const box = document.createElement('div');
    box.style.position = 'fixed';
    box.style.top = '10px';
    box.style.right = '10px';
    box.style.width = '450px';
    box.style.maxHeight = '80vh';
    box.style.overflowY = 'auto';
    box.style.backgroundColor = '#fff';
    box.style.color = '#000';
    box.style.border = '3px solid #333';
    box.style.padding = '15px';
    box.style.zIndex = '999999';
    box.style.fontFamily = 'sans-serif';
    box.style.boxShadow = '0 0 15px rgba(0,0,0,0.5)';
    box.style.borderRadius = '8px';

    // 3. Добавляем заголовок и кнопку закрытия
    box.innerHTML = `
        <div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; border-bottom:1px solid #ccc; padding-bottom:5px;">
            <h3 style="margin:0; font-size:16px;">Найдено ссылок: ${links.length}</h3>
            <button id="close-links-btn" style="cursor:pointer; background:#ff4d4d; color:white; border:none; padding:4px 8px; border-radius:4px;">Закрыть</button>
        </div>
        <ol style="padding-left:20px; margin:0; font-size:12px; line-height:1.5; text-align:left;"></ol>
    `;

    // 4. Заполняем список ссылками
    const list = box.querySelector('ol');
    links.forEach(url => {
        const li = document.createElement('li');
        li.style.marginBottom = '5px';
        li.style.wordBreak = 'break-all';
        li.innerHTML = `<a href="${url}" target="_blank" style="color:#0066cc; text-decoration:underline;">${url}</a>`;
        list.appendChild(li);
    });

    // 5. Выводим окно на экран
    document.body.appendChild(box);

    // 6. Логика закрытия окна
    box.querySelector('#close-links-btn').onclick = () => box.remove();
})();