Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- //prwtes dyo erotisis
- var question1Title = document.querySelectorAll("h2")[0].innerText;
- var question1Answer = document.querySelectorAll("h2")[0].nextElementSibling.innerText;
- var question2Title = document.querySelectorAll("h2")[1].innerText;
- var question2Answer = document.querySelectorAll("h2")[1].nextElementSibling.innerText;
- //dimiourgia tou javascript tag
- var scriptTag = document.createElement("script");
- scriptTag.type = "application/ld+json";
- //periexomeno tou javascript tag
- scriptTag.textContent = JSON.stringify({
- "@context": "https://schema.org",
- "@type": "FAQPage",
- "mainEntity": [
- {
- "@type": "Question",
- "name": question1Title,
- "acceptedAnswer": {
- "@type": "Answer",
- "text": question1Answer
- }
- },
- {
- "@type": "Question",
- "name": question2Title,
- "acceptedAnswer": {
- "@type": "Answer",
- "text": question2Answer
- }
- }
- ]
- });
- //prosthiki tou script element sto kefali
- document.head.appendChild(scriptTag);
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement