Created
September 5, 2012 08:02
-
-
Save franzenzenhofer/3632965 to your computer and use it in GitHub Desktop.
greasmonkey / chrome - userscript -shows important SEO head information
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
// ==UserScript== | |
// @name shows important SEO head information | |
// @namespace http://www.facesaerch.com/ | |
// @description show canonical, noindex, nofollow | |
// @include * | |
// ==/UserScript== | |
function trim12 (str) { | |
var str = str.replace(/^\s\s*/, ''), | |
ws = /\s/, | |
i = str.length; | |
while (ws.test(str.charAt(--i))); | |
return str.slice(0, i + 1); | |
} | |
var allElements, thisElement; | |
allElements = document.getElementsByTagName('link'); | |
var mybody, newElement, newElement2; | |
mybody = document.getElementsByTagName('body'); | |
for (var i = 0; i < allElements.length; i++) { | |
thisElement = allElements[i]; | |
if(thisElement.getAttribute('rel')=='canonical') | |
{ | |
if (mybody[0]) { | |
if(thisElement.getAttribute('href')!=document.location) | |
{ | |
bg="yellow"; | |
bor="red"; | |
c="blue"; | |
var link = true; | |
} | |
else | |
{ | |
bg="lightyellow"; | |
bor="gray"; | |
c="black"; | |
var link = false; | |
} | |
newElement = document.createElement('div'); | |
newElement.setAttribute('id', 'canonicaldebug'); | |
newElement.setAttribute('style', 'position:fixed; left:5px; top:5px; z-index: 9999999; border: 1px solid '+bor+'; background-color: '+bg+'; padding: 2px; font: 9px arial; color: '+c+'";'); | |
if(link==true) | |
{ | |
newElement.innerHTML="<a href='"+thisElement.getAttribute('href')+"' style='color:blue;' >"+thisElement.getAttribute('href')+"</a>"; | |
} | |
else | |
{ | |
newElement.innerHTML=thisElement.getAttribute('href'); | |
} | |
mybody[0].parentNode.insertBefore(newElement, mybody[0]); | |
} | |
} | |
} | |
//robotsS | |
allMeta = document.getElementsByTagName('meta'); | |
var rc=''; | |
for (var i = 0; i < allMeta.length; i++) | |
{ | |
thisElement = allMeta[i]; | |
if(thisElement.getAttribute('name')=='robots') | |
{ | |
rc=rc+' '+thisElement.getAttribute('content'); | |
} | |
else if(thisElement.getAttribute('name')=='googlebot') | |
{ | |
rc=rc+' '+thisElement.getAttribute('content'); | |
} | |
} | |
rc=trim12(rc); | |
if(rc!='') | |
{ | |
//alert(rc); | |
newElement2 = document.createElement('div'); | |
if((rc.search('noindex')!=-1)|(rc.search('nofollow')!=-1)) | |
{ | |
bg="yellow"; | |
bor="red"; | |
c="blue"; | |
//alert(rc.search('noindex')); | |
} | |
else | |
{ | |
bg="lightyellow"; | |
bor="gray"; | |
c="black"; | |
} | |
if(document.getElementById('canonicaldebug')) | |
{ | |
toppx="25"; | |
} | |
else | |
{ | |
toppx="5"; | |
} | |
newElement2.setAttribute('style', 'position:fixed; left:5px; top:'+toppx+'px; z-index: 9999999; border: 1px solid '+bor+'; background-color: '+bg+'; padding: 2px; font: 9px arial; color: '+c+' !important";'); | |
newElement2.innerHTML=rc; | |
document.body.parentNode.insertBefore(newElement2, mybody[0]); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment