Skip to content

Instantly share code, notes, and snippets.

@LaboratorioEfe5
Last active August 14, 2017 12:29
Show Gist options
  • Save LaboratorioEfe5/7794804 to your computer and use it in GitHub Desktop.
Save LaboratorioEfe5/7794804 to your computer and use it in GitHub Desktop.
Bookmarklet para mostrar los datos relativos al theme actual si la página está construida con el CMS WordPress.
var links = document.getElementsByTagName("link");
var neededElements = [];
var reg= /\/wp-content\/themes\/(.)+\/style\.css/;
var themeStyle ='';
for (var i = 0, length = links.length; i < length; i++) {
if (links[i].rel.indexOf('stylesheet') >= 0) {
if (links[i].href.match(reg)){
themeStyle = links[i].href;
}
}
}
if(themeStyle===''){
alert('Vaya parece que la web actual no está construida con WordPress');
return false;
}
var txtFile = new XMLHttpRequest();
txtFile.open("GET", themeStyle, true);
txtFile.onreadystatechange = function()
{
if (txtFile.readyState === 4) { // document is ready to parse.
if (txtFile.status === 200) { // file is found
allText = txtFile.responseText;
themeName = allText.match(/theme name:(.)+/i)||{};
themeURI = allText.match(/theme URI:(.)+/i)||{};
description = allText.match(/Description:(.)+/i)||{};
author = allText.match(/Author:(.)+/i)||{};
authorURI = allText.match(/Author URI:(.)+/i)||{};
version = allText.match(/Version:(.)+/i)||{};
tags = allText.match(/Tags:(.)+/i)||{};
alert(themeName[0]+'\n'+themeURI[0]+'\n'+description[0]+'\n'+author[0]+'\n'+authorURI[0]+'\n'+version[0]+'\n'+tags[0]);
}
}
};
txtFile.send(null);
javascript:(function(){var links=document.getElementsByTagName("link");var neededElements=[];var reg=/\/wp-content\/themes\/(.)+\/style\.css/;var themeStyle="";for(var i=0,length=links.length;i<length;i++)if(links[i].rel.indexOf("stylesheet")>=0)if(links[i].href.match(reg))themeStyle=links[i].href;if(themeStyle===""){alert("Vaya parece que la web actual no est\u00e1 construida con WordPress");return false;}var txtFile=new XMLHttpRequest;txtFile.open("GET",themeStyle,true);txtFile.onreadystatechange=function(){if(txtFile.readyState===4)if(txtFile.status===200){allText=txtFile.responseText;themeName=allText.match(/theme name:(.)+/i)||{};themeURI=allText.match(/theme URI:(.)+/i)||{};description=allText.match(/Description:(.)+/i)||{};author=allText.match(/Author:(.)+/i)||{};authorURI=allText.match(/Author URI:(.)+/i)||{};version=allText.match(/Version:(.)+/i)||{};tags=allText.match(/Tags:(.)+/i)||{};alert(themeName[0]+"\n"+themeURI[0]+"\n"+description[0]+"\n"+author[0]+"\n"+authorURI[0]+"\n"+version[0]+"\n"+tags[0])}};txtFile.send(null);})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment