請將以下步驟作為工作檢查清單,並依據專案的證據、範圍與限制調整。
實用步驟
- 開啟要檢查的頁面和瀏覽器開發人員主控台。行動版溢位檢查器請先使用回應式模式。
- 檢查程式碼,將完整片段貼到主控台並按 Enter。它會讀取目前頁面;只有 sitemap 中繼資料工具和同源檢查器會發出有限的請求。
- 檢視主控台輸出或下載的 CSV/JSON。瀏覽器政策、驗證狀態和不支援的伺服器方法可能導致部分檢查無法得出結論。
(() => {
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.');
})();執行前請先審查。此指令碼會讀取目前頁面;只有 sitemap 和連結稽核會發出有限的同源請求。請求不會帶上 cookies;指令碼不會變更網站內容。