1jQuery(document).ready(function() { 2 3 // URL 4 if (!URL) return; 5 6 const breadcrumbSelector = '.breadcrumb:not(.loaded)'; 7 const breadcrumbItemSelector = 'a.breadcrumb-item, .breadcrumb-item a'; 8 9 // ãã³ã¯ãºè¤æ° 10 const breadcrumbLists = new Array(); 11 jQuery(breadcrumbSelector).each(function() { 12 13 // ãã³ã¯ãº 14 const breadcrumbList = { 15 '@context': 'http://schema.org', 16 '@type': 'BreadcrumbList', 17 'itemListElement': new Array() 18 } 19 20 let position = 0; 21 jQuery(this).find(breadcrumbItemSelector).each(function() { 22 23 // ãããã¯é¤å¤ 24 if (position == 0) { 25 position++; 26 return true; 27 } 28 29 // ãªã³ã¯åå¾ 30 let href; 31 if (jQuery(this).attr('href')) 32 href = jQuery(this).attr('href'); 33 else if (jQuery(this).find('a[href]').length > 0) 34 href = jQuery(this).find('a[href]').href; 35 if (!href) return true; 36 const url = new URL(href, document.location.origin); 37 38 // ãªã³ã¯ååå¾ 39 const text = jQuery(this).text(); 40 41 // ãã³ã¯ãºè¨å® 42 const listItem = { 43 '@type': 'ListItem', 44 'position': position, 45 'item': { 46 '@id': url.href, 47 'name': text 48 } 49 }; 50 breadcrumbList.itemListElement.push( listItem ); 51 52 position++; 53 }); 54 55 if (!breadcrumbList.itemListElement.length) return true; 56 57 breadcrumbLists.push( breadcrumbList ); 58 jQuery(this).addClass('loaded'); 59 }); 60 61 // 0ä»¶ãªãã°çµäº 62 if (!breadcrumbLists || breadcrumbLists.length == 0) return; 63 64 // JSON-LDåºå 65 const scriptTag = jQuery('<script></script>'); 66 scriptTag.attr('type', 'application/ld+json'); 67 if (breadcrumbLists.length == 1) { 68 scriptTag.text( JSON.stringify(breadcrumbLists[0]) ); 69 } else { 70 scriptTag.text( JSON.stringify(breadcrumbLists) ); 71 } 72 const target = jQuery('head') ? jQuery('head') : 73 jQuery('body') ? jQuery('body') : 74 jQuery(':root'); 75 target.append(scriptTag); 76 77});
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.