Potraktuj te kroki jako listę roboczą i dostosuj je do danych, zakresu oraz ograniczeń projektu.
Praktyczne wskazówki
- Otwórz sprawdzaną stronę i konsolę deweloperską przeglądarki. Przed kontrolą przepełnienia mobilnego włącz widok responsywny.
- Sprawdź kod, wklej cały skrypt do konsoli i naciśnij Enter. Odczytuje bieżącą stronę; tylko audyt sitemap i kontrolery linków wykonują ograniczone żądania do tej samej domeny.
- Sprawdź wynik w konsoli lub pobrany plik CSV/JSON. Zasady przeglądarki, logowanie i nieobsługiwane metody serwera mogą sprawić, że część wyników będzie niejednoznaczna.
(() => {
const MAX_LINKS = 5000;
const allLinks = document.links;
const links = Array.from({ length: Math.min(allLinks.length, MAX_LINKS) }, (_, index) => allLinks[index]).map((link) => {
const url = new URL(link.href, location.href);
const text = [link.innerText, link.getAttribute('aria-label'), link.title]
.map((value) => (value || '').trim().replace(/\s+/g, ' '))
.find(Boolean) || '';
return {
text,
url: url.href,
type: url.origin === location.origin ? 'internal' : 'external',
target: link.target || '',
rel: link.rel || '',
nofollow: link.relList.contains('nofollow'),
ariaLabel: link.getAttribute('aria-label') || '',
};
});
console.table(links);
const quote = (value) => '"' + String(value).replace(/[\u0000-\u0020]*[=+\-@]/, (match) => "'" + match).replace(/"/g, '""') + '"';
const columns = ['text', 'url', 'type', 'target', 'rel', 'nofollow', 'ariaLabel'];
const csv = '\uFEFF' + [columns, ...links.map((row) => columns.map((column) => row[column] ?? ''))].map((row) => row.map(quote).join(',')).join('\r\n');
const a = document.createElement('a'); a.href = URL.createObjectURL(new Blob([csv], { type: 'text/csv;charset=utf-8' })); a.download = 'page-links.csv'; a.click(); setTimeout(() => URL.revokeObjectURL(a.href), 1000);
console.info('Exported ' + links.length + ' links from the current page.');
if (allLinks.length > MAX_LINKS) console.warn('Only the first ' + MAX_LINKS + ' of ' + allLinks.length + ' links were exported.');
})();Sprawdź kod przed uruchomieniem. Odczytuje bieżącą stronę; tylko audyt sitemap i linków wykonuje ograniczone żądania do tej samej domeny bez plików cookie. Nie zmienia treści witryny.