Anchor Text Checker
body {background:#f8f9fa;} textarea{font-size:.9rem;} .progress-area{white-space:pre-wrap;font-size:.9rem;}
Anchor Text Checker
Backlink URLs (one per line)
Target Domain (your site)
Keywords / Anchor Texts (comma-separated)
Generate Excel
Show Log ▾
Download CSV
// Use pure JavaScript – outputs CSV to avoid external libraries (better for WordPress/Blogger).
// Paste in Code/HTML editor so quotes stay straight.
(function(){
const form = document.getElementById(‘checkerForm’);
const progressEl = document.getElementById(‘progress’);
const toggleLogBtn = document.getElementById(‘toggleLogBtn’);
toggleLogBtn.addEventListener(‘click’, ()=>{
const shown = progressEl.style.display !== ‘none’;
progressEl.style.display = shown ? ‘none’ : ‘block’;
toggleLogBtn.textContent = shown ? ‘Show Log ▾’ : ‘Hide Log ▴’;
});
const downloadBtn = document.getElementById(‘downloadBtn’);
// revoke object URL after click to free memory
downloadBtn.addEventListener(‘click’, ()=>{
setTimeout(()=>URL.revokeObjectURL(downloadBtn.href), 1500);
});
form.addEventListener(‘submit’, async (e)=>{
e.preventDefault();
progressEl.textContent=’Starting…\n’;
const progressBar = document.getElementById(‘progressBar’);
const progressBarContainer = document.getElementById(‘progressBarContainer’);
progressBarContainer.style.display = ‘block’;
const backlinks = document.getElementById(‘backlinks’).value.split(/\n/).map(s=>s.trim()).filter(Boolean);
const domain = document.getElementById(‘domain’).value.trim();
const keywords = document.getElementById(‘keywords’).value.split(‘,’).map(s=>s.trim()).filter(Boolean);
if(!backlinks.length){alert(‘Please enter at least one backlink URL’);return;}
if(!domain){alert(‘Enter target domain’);return;}
const rows=[];
let processed=0;
const concurrency=8;
async function processUrl(url, idx){
const progress = Math.round((processed / backlinks.length) * 100);
progressBar.style.width = `${progress}%`;
progressBar.textContent = `${progress}%`;
progressEl.textContent+=`[${idx+1}/${backlinks.length}] Fetching: ${url}\n`;
// Enhanced proxy list with fallbacks
const proxies = [
‘
https://api.allorigins.win/raw?url=’,
‘
https://thingproxy.freeboard.io/fetch/’,
‘
https://r.jina.ai/http://’,
‘
https://corsproxy.io/?’,
‘
https://api.codetabs.com/v1/proxy/?quest=’
];
const html = await (async function fetchWithRetries(round) {
for(const p of proxies) {
try {
progressEl.textContent += ` Trying proxy: ${p.split(‘/’)[2]}…\n`;
const resp = await fetch(p + encodeURIComponent(url), {
headers: { ‘User-Agent’: ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36’ },
mode: ‘cors’,
cache: ‘no-cache’
});
if (resp.ok) {
const text = await resp.text();
if (text && !text.includes(‘Access Denied’) && !text.includes(‘captcha’)) {
return text;
}
}
} catch(e) {
// Log proxy failure but continue to next one
progressEl.textContent += ` Proxy ${p.split(‘/’)[2]} failed: ${e.message}\n`;
}
}
if(round>=3) return null;
progressEl.textContent+=` retrying (${round})…\n`;
await new Promise(r=>setTimeout(r,800));
return fetchWithRetries(round+1);
})(1);
if(!html){
progressEl.textContent+=`❌ Failed to fetch: ${url} (all proxies exhausted)\n`;
rows.push({‘Backlink URL’:url,’Anchor Text’:’ERROR: Failed to fetch (see log)’,’Matched Keyword’:”});
return;
}
const doc=new DOMParser().parseFromString(html,’text/html’);
const anchors=Array.from(doc.querySelectorAll(‘a’));
const matches=anchors.filter(a=>a.href&&a.href.toLowerCase().includes(domain.toLowerCase()));
if(matches.length===0){rows.push({‘Backlink URL’:url,’Anchor Text’:'(no link)’,’Matched Keyword’:”});}
else{
matches.forEach(a=>{
const text=a.textContent.trim();
const matched=keywords.find(k=>k.toLowerCase()===text.toLowerCase())||”;
rows.push({‘Backlink URL’:url,’Anchor Text’:text,’Matched Keyword’:matched});
});
}
processed++;
}
const queue=[…backlinks.entries()];
const workers=[];
for(let i=0;i{
csvLines.push([r[‘Backlink URL’], r[‘Anchor Text’].replace(/”/g,’””‘), r[‘Matched Keyword’]].map(x=>`”${x}”`).join(‘,’));
});
const csvContent = ‘\uFEFF’ + csvLines.join(‘\n’); // prepend BOM so Excel opens UTF-8 correctly
const blob = new Blob([csvContent], {type:’text/csv’});
const downloadUrl = URL.createObjectURL(blob);
downloadBtn.href = downloadUrl;
downloadBtn.download = ‘anchor_report.csv’;
downloadBtn.style.display = ‘inline-block’;
progressBar.style.width = ‘100%’;
progressBar.textContent = ‘100%’;
progressBar.style.backgroundColor = ‘#28a745’; // Ensure green color
progressEl.textContent += ‘\n✅ Finished! Click “Download CSV” to save the file.’;
});
})();
Leave a comment