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.
(async () => {
const MAX_URLS = 200;
const CONCURRENCY = 4;
const TIMEOUT_MS = 10000;
const deadline = Date.now() + 45000;
const origin = location.origin;
const allUrls = [...new Set([...document.links].map((link) => {
try { const url = new URL(link.href); url.hash = ''; return url.origin === origin && /^https?:$/.test(url.protocol) ? url.href : ''; } catch { return ''; }
}).filter(Boolean))];
const urls = allUrls.slice(0, MAX_URLS);
const results = new Array(urls.length);
let cursor = 0;
async function worker() {
while (cursor < urls.length && Date.now() < deadline) {
const index = cursor++;
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), Math.min(TIMEOUT_MS, deadline - Date.now()));
try {
const response = await fetch(urls[index], { method: 'HEAD', credentials: 'omit', redirect: 'follow', cache: 'no-store', signal: controller.signal });
results[index] = { url: urls[index], status: response.status, finalUrl: response.url, result: response.status === 405 || response.status === 501 ? 'HEAD unsupported; check manually' : response.ok ? 'OK' : 'HTTP error' };
} catch (error) {
results[index] = { url: urls[index], status: '', finalUrl: '', result: error.name === 'AbortError' ? 'timeout' : 'blocked or network error' };
} finally { clearTimeout(timer); }
}
}
await Promise.all(Array.from({ length: Math.min(CONCURRENCY, urls.length) }, worker));
for (let index = 0; index < urls.length; index++) if (!results[index]) results[index] = { url: urls[index], status: '', finalUrl: '', result: 'not checked: 45-second runtime limit' };
console.table(results);
if (allUrls.length > MAX_URLS) console.warn('Only the first ' + MAX_URLS + ' of ' + allUrls.length + ' unique internal URLs were checked.');
console.info('Checked ' + results.filter((row) => !row.result.startsWith('not checked')).length + ' of ' + urls.length + ' unique same-origin links with HEAD requests. Limits: ' + MAX_URLS + ' links and 45 seconds. Unsupported HEAD, access restrictions, or browser policy can make a result inconclusive. No cookies were sent.');
})();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.