Untitled
unknown
plain_text
a year ago
1.8 kB
6
Indexable
javascript:(function()%7B(function()%7Bfunction extractTextAndHeaderSrc(content) %7B%0A const textArray %3D %5B%5D%3B %2F%2F Create an empty array to store extracted text and header%0A%0A %2F%2F Loop through each element in the content object%0A content.elements.forEach(element %3D> %7B%0A if (element.type %3D%3D%3D "text") %7B%0A %2F%2F If the element type is "text"%2C create a paragraph element with a class "article-text" and push it to the textArray%0A textArray.push("<p class%3D%5C"article-text%5C">"%2Belement.text%2B"<%2Fp>")%3B%0A %7D else if (element.type %3D%3D%3D "header") %7B%0A %2F%2F If the element type is "header"%2C create a paragraph element with a class "article-header" and push it to the textArray%0A textArray.push("<p class%3D%5C"article-header%5C">"%2Belement.text%2B"<%2Fp>")%3B%0A %7D else if (element.type %3D%3D%3D "image") %7B%0A %2F%2F If the element type is "image"%2C create a div element with a class "Imagestyled__Container-sc-12smbns-0 eYSdmX"%2C containing an image element with a source (src) value from the element's imageInfo object%2C and push it to the textArray%0A textArray.push("<div data-testid%3D%5C"image%5C" class%3D%5C"Imagestyled__Container-sc-12smbns-0 eYSdmX%5C"><img src%3D"%2Belement.imageInfo.src%2B"><%2Fdiv>")%3B%0A %7D%0A %7D)%3B%0A%0A %2F%2F Return an object with the extracted text and header as a property called "text"%0A return textArray.join("")%3B%0A%7D%0A%0Aconst text %3D extractTextAndHeaderSrc(Fusion.globalContent)%3B%0Adocument.body.innerHTML %3D text%3Bdocument.body.style.fontSize %3D "1.7em"%3Btext%3Bdocument.body.style.maxWidth %3D "500px"%3Bdocument.body.style.margin %3D "10px auto"%3Bdocument.body.style.background %3D "white"%7D)()%3B%7D)()%3B
Editor is loading...
Leave a Comment