Skip to content

Instantly share code, notes, and snippets.

@sajjadmd
Created October 9, 2019 16:34
Show Gist options
  • Save sajjadmd/05ee1dda6a4fe2cebbce6ffb1a83c293 to your computer and use it in GitHub Desktop.
Save sajjadmd/05ee1dda6a4fe2cebbce6ffb1a83c293 to your computer and use it in GitHub Desktop.
SEO script, quick JSON-LD structured data view/check.
(function() {
clear();
let results = [];
const j = document.querySelectorAll("script[type='application/ld+json']");
const items = j.forEach((i) => {
let json = i.innerHTML;
try {
json = ["OK", "color:green;font-size:13px;", JSON.stringify(JSON.parse(json), null, 2)];
} catch (err) {
json = ["ERROR", "color:red;font-size:13px;", json];
}
results.push(json);
});
for (const J of results) {
console.log("%c" + J[0], J[1]);
console.log(J[2]);
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment