Skip to content

Instantly share code, notes, and snippets.

@Steveseo73
Steveseo73 / seo-metadata-checker.js
Created October 26, 2024 20:55
checks title of webpage in google serps to see if it is the same as in the webpage url
javascript:(function(){const s=document.createElement('style');s.textContent=`.tc{margin-top:8px;font-size:14px}.tm{color:#0f5132;background:#d1e7dd;padding:2px%206px;border-radius:3px}.tmm{color:#842029;background:#f8d7da;padding:2px%206px;border-radius:3px}.te{color:#664d03;background:#fff3cd;padding:2px%206px;border-radius:3px}`;document.head.appendChild(s);const%20p=['https://corsproxy.io/?','https://api.allorigins.win/raw?url='];let%20c=0;const%20g=()=>Array.from(document.querySelectorAll('div.g:not(.kno-kp%20.g)%20div[data-snf]%20a:has(h3)')).map((l,i)=>({p:i+1,e:l.closest('div.g'),t:l.querySelector('h3').textContent,u:l.href}));const%20f=async%20u=>{const%20x=p[Math.floor(Math.random()*p.length)]+encodeURIComponent(u);const%20r=await%20fetch(x);const%20h=await%20r.text();const%20d=(new%20DOMParser).parseFromString(h,'text/html');return%20d.title.trim()};const%20d=(e,g,a,r=false)=>{const%20v=document.createElement('div');v.className='tc';if(r)v.innerHTML='<span%20class="te">Error%20fetching%20page%20tit