Gunakan langkah ini sebagai senarai semak kerja dan sesuaikannya dengan bukti, skop serta kekangan projek.
Langkah praktikal
- Buka halaman yang ingin diperiksa dan konsol pembangun pelayar. Gunakan mod responsif dahulu untuk pemeriksa limpahan mudah alih.
- Semak kod, tampal keseluruhan petikan ke dalam konsol dan tekan Enter. Ia membaca halaman semasa; hanya alat metadata sitemap dan pemeriksa same-origin membuat permintaan yang terhad.
- Semak output konsol atau CSV/JSON yang dimuat turun. Dasar pelayar, pengesahan dan kaedah pelayan yang tidak disokong boleh menyebabkan sesetengah semakan tidak dapat dipastikan.
(() => {
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.');
})();Semak sebelum menjalankan. Skrip membaca halaman semasa; hanya audit sitemap dan pautan membuat permintaan same-origin yang terhad. Permintaan tidak menghantar cookies; skrip tidak mengubah kandungan laman.