Skip to content

Instantly share code, notes, and snippets.

@Wilman-es
Created February 1, 2024 17:13
Show Gist options
  • Save Wilman-es/ac7727ed7b772abe99e2c6d9f80eded0 to your computer and use it in GitHub Desktop.
Save Wilman-es/ac7727ed7b772abe99e2c6d9f80eded0 to your computer and use it in GitHub Desktop.
Bookmarklet Extract schema
javascript:(()=>{function e(){var e=document.querySelectorAll('script[type="application/ld+json"]'),n=[];e.length>0?(e.forEach(function(e,t){try{var l=JSON.parse(e.textContent);!function e(t){if(t&&"object"==typeof t&&t["@type"])for(var l in n.push(t["@type"]),t)null!==t[l]&&"object"==typeof t[l]&&e(t[l])}(l)}catch(o){console.error("Error parsing JSON-LD block "+(t+1)+":",o)}}),n.length>0?t(n):alert("No se encontraron tipos (@type) en los bloques JSON-LD v\xe1lidos en la p\xe1gina.")):alert("No se encontraron bloques JSON-LD en la p\xe1gina.")}function t(e){var t=document.createElement("div");t.style.position="fixed",t.style.top="50%",t.style.left="50%",t.style.width="400px",t.style.height="350px",t.style.background="#000",t.style.color="#00ff00",t.style.fontSize="140%",t.style.border="1px solid #00ff00",t.style.overflow="auto",t.style.zIndex="9999",t.style.marginTop="-100px",t.style.marginLeft="-150px",t.style.textAlign="center";var n=document.createElement("div");n.style.fontWeight="bold",n.style.padding="10px",n.textContent="Lista de tipos de marcado Schema";var l=document.createElement("button");l.textContent="Cerrar",l.style.position="absolute",l.style.bottom="10px",l.style.left="50%",l.style.transform="translateX(-50%)",l.style.background="#00ff00",l.style.color="#000",l.addEventListener("click",function(){document.body.removeChild(t)});var o=document.createElement("ul");o.style.listStyleType="none",o.style.padding="0",e.forEach(function(e){var t=document.createElement("li");t.textContent=e,o.appendChild(t)}),t.appendChild(n),t.appendChild(l),t.appendChild(o),document.body.appendChild(t)}e()})();
@Wilman-es
Copy link
Author

This (bookmarklet) JavaScript code is a handy tool that you can run on a webpage to figure out what kind of structured data is hiding in the background. It looks for script elements with a specific type ("application/ld+json"), which is often used to store structured information like Schema.org markup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment