Created
August 18, 2020 03:10
-
-
Save tjkelly/a2aa1f4d2d1f1c87510a10b5669272f2 to your computer and use it in GitHub Desktop.
Based on Glen Allsop's "Advanced Google Chrome Bookmarklets for SEOs" — I got tired of getting the URL slug caught up in list, so I edited the JS a bit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){output="<html><head>";output+="<title>SEO SERP Extraction Tool</title>";output+='<style type="text/css">';output+="*{font-family:georgia;word-break:break-all}";output+="</style>";output+="</head><body>";pageAnchors=document.getElementsByTagName("a");divClasses=document.getElementsByTagName("div");var linkcount=0;var linkLocation="";var linkAnchorText="";output+="<h1>Results</h1>";output+='<div id="wrap"><table border="1" cellspacing="0" cellpadding="4"><th>#</th><th>Link</th><th>Anchor</th>';for(i=0;i<pageAnchors.length;i++){if(pageAnchors[i].parentNode.parentNode.getAttribute("class")!="iUh30"){var anchorText=pageAnchors[i].textContent;for(j=0;j<pageAnchors[i].childNodes.length;j++){if(pageAnchors[i].childNodes[j].className=="LC20lb DKV0Md"){var anchorText=pageAnchors[i].childNodes[j].textContent}}var anchorLink=pageAnchors[i].href;var linkAnchor=anchorLink+"\t"+anchorText;var anchorID=pageAnchors[i].id;if(anchorLink!=""){if(anchorLink.match(/^((?!google\.|cache|blogger.com|\.yahoo\.|youtube\.com\/\?gl=|youtube\.com\/results|javascript:|api\.technorati\.com|botw\.org\/search|del\.icio\.us\/url\/check|digg\.com\/search|search\.twitter\.com\/search|search\.yahoo\.com\/search|siteanalytics\.compete\.com|tools\.seobook\.com\/general\/keyword\/suggestions|web\.archive\.org\/web\/|whois\.domaintools\.com|www\.alexa\.com\/data\/details\/main|www\.bloglines\.com\/search|www\.majesticseo\.com\/search\.php|www\.semrush\.com\/info\/|www\.semrush\.com\/search\.php|www\.stumbleupon\.com\/url|wikipedia.org\/wiki\/Special:Search).)*$/i)){if(anchorID.match(/^((?!hdtb_more|hdtb_tls|uh_hl).)*$/i)){linkLocation+=anchorLink+"</li><li>";linkAnchorText+=anchorText+"</li><li>";linkcount++;if(anchorText===undefined){anchorText=pageAnchors[i].innerText}output+="<tr>";output+="<th>"+linkcount+"</th>";output+="<td>"+pageAnchors[i].href+"</a></td>";output+="<td>"+anchorText+"</td>";output+="</tr>\n"}}}}}output+="</table></div><br/><hr>";output+="<h1>URL List</h1>";output+="<ul><li>"+linkLocation+"</ul>";output+="<br/><hr>";output+="<h1>Anchor Text List</h1>";output+="<ul><li>"+linkAnchorText+"</ul>";output+="</body></html>";with(window.open()){document.write(output);document.close()}})(); | |
/*! | |
* Unminified Code | |
* | |
* @author TJ Kelly - https://getmxt.com | |
* | |
* @date 2020-08-17 | |
* | |
* @notes | |
* Based on Glen Allsop's "Advanced Google Chrome Bookmarklets for SEOs" | |
* https://detailed.com/chrome-bookmarklets-seo/ | |
* | |
* I got tired of getting the URL slug caught up in list, so I edited the JS a bit. | |
*/ | |
javascript: (function () { | |
output = "<html><head>"; | |
output += "<title>SEO SERP Extraction Tool</title>"; | |
output += '<style type="text/css">'; | |
output += "*{font-family:georgia;word-break:break-all}"; | |
output += "</style>"; | |
output += "</head><body>"; | |
pageAnchors = document.getElementsByTagName("a"); | |
divClasses = document.getElementsByTagName("div"); | |
var linkcount = 0; | |
var linkLocation = ""; | |
var linkAnchorText = ""; | |
output += "<h1>Results</h1>"; | |
output += '<div id="wrap"><table border="1" cellspacing="0" cellpadding="4"><th>#</th><th>Link</th><th>Anchor</th>'; | |
for (i = 0; i < pageAnchors.length; i++) { | |
if (pageAnchors[i].parentNode.parentNode.getAttribute("class") != "iUh30") { | |
var anchorText = pageAnchors[i].textContent; | |
for (j = 0; j < pageAnchors[i].childNodes.length; j++) { | |
if (pageAnchors[i].childNodes[j].className == "LC20lb DKV0Md") { | |
var anchorText = pageAnchors[i].childNodes[j].textContent | |
} | |
} | |
var anchorLink = pageAnchors[i].href; | |
var linkAnchor = anchorLink + "\t" + anchorText; | |
var anchorID = pageAnchors[i].id; | |
if (anchorLink != "") { | |
if (anchorLink.match(/^((?!google\.|cache|blogger.com|\.yahoo\.|youtube\.com\/\?gl=|youtube\.com\/results|javascript:|api\.technorati\.com|botw\.org\/search|del\.icio\.us\/url\/check|digg\.com\/search|search\.twitter\.com\/search|search\.yahoo\.com\/search|siteanalytics\.compete\.com|tools\.seobook\.com\/general\/keyword\/suggestions|web\.archive\.org\/web\/|whois\.domaintools\.com|www\.alexa\.com\/data\/details\/main|www\.bloglines\.com\/search|www\.majesticseo\.com\/search\.php|www\.semrush\.com\/info\/|www\.semrush\.com\/search\.php|www\.stumbleupon\.com\/url|wikipedia.org\/wiki\/Special:Search).)*$/i)) { | |
if (anchorID.match(/^((?!hdtb_more|hdtb_tls|uh_hl).)*$/i)) { | |
linkLocation += anchorLink + "</li><li>"; | |
linkAnchorText += anchorText + "</li><li>"; | |
linkcount++; | |
if (anchorText === undefined) { | |
anchorText = pageAnchors[i].innerText | |
} | |
output += "<tr>"; | |
output += "<th>" + linkcount + "</th>"; | |
output += "<td>" + pageAnchors[i].href + "</a></td>"; | |
output += "<td>" + anchorText + "</td>"; | |
output += "</tr>\n" | |
} | |
} | |
} | |
} | |
} | |
output += "</table></div><br/><hr>"; | |
output += "<h1>URL List</h1>"; | |
output += "<ul><li>" + linkLocation + "</ul>"; | |
output += "<br/><hr>"; | |
output += "<h1>Anchor Text List</h1>"; | |
output += "<ul><li>" + linkAnchorText + "</ul>"; | |
output += "</body></html>"; | |
with(window.open()) { | |
document.write(output); | |
document.close() | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment