1(function(){ 2 function create_schemaorg_website(){ 3 4 /* create script tag */ 5 var script = document.createElement("script"); 6 script.setAttribute("type", "application/ld+json"); 7 8 /* create website_json */ 9 var website_obj = { 10 "@context": "https://schema.org", 11 "@type": "BreadcrumbList", 12 "itemListElement": [] 13 } 14 // website_obj["itemListElement"] = []; 15 var items = document.querySelectorAll('div.l-breadcrumbs.u-pc-only > div > ol > li > a'); 16 var i = 1; 17 for (var key=0; key < items.length; key++) { 18 var item = items[key]; 19 website_obj["itemListElement"].push({ 20 "@type":"ListItem", 21 "position": i, 22 "item": { 23 "@id":item.href, 24 "name": item.innerText 25 } 26 }); 27 i++; 28 } 29 // current 30 item = document.querySelector('.breadcrumb__page-title'); 31 if (item !== null) { 32 website_obj["itemListElement"].push({ 33 "@type":"ListItem", 34 "position": i, 35 "item": { 36 "@id": document.URL, 37 "name": item.innerText 38 } 39 }); 40 } 41 if (i > 1) { 42 script.innerText = JSON.stringify(website_obj); 43 document.head.appendChild(script); 44 } 45 } 46 window.addEventListener("load", create_schemaorg_website, false); 47}());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.