function insertCollectibleImageBeforePreTag() { // Find the
tag in the document
const preTag = document.querySelector('pre');
if (!preTag) {
console.error('No tag found in the document.');
return;
}
// Parse the JSON content of the tag
let jsonData;
try {
jsonData = JSON.parse(preTag.textContent);
} catch (error) {
console.error('Invalid JSON content in the tag.');
return;
}
// Check if the "type" value is an array containing "VerifiableCollectible"
const typeArray = jsonData.type;
if (Array.isArray(typeArray) && typeArray.includes('VerifiableCollectible')) {
const imageSrc = jsonData.credentialSubject?.image;
if (imageSrc) {
// Create an
tag and set its "src" attribute
const imgTag = document.createElement('img');
imgTag.src = imageSrc;
// Insert the
tag before the tag
preTag.parentNode.insertBefore(imgTag, preTag);
} else {
console.error('No "credentialSubject.image" property found in the JSON data.');
}
} else {
console.error('The JSON data does not meet the required conditions.');
}
}