1// The css mark positioning. 2function jsoutput() { 3 window.addEventListener( 'load', function() { 4 var mark = '<span class="blogreachmark">' + settings.post_meta['blogreach_custom_mark'] + '</span>'; 5 var legend = '<span class="blogreachlegend">' + settings.post_meta['blogreach_custom_legend'] + '</span>'; 6 if ( settings.options['blogreach_positions_after_css'] ) { 7 if ( settings.options['blogreach_positions_after_css_selector'] ) { 8 9 // Add the mark to the selected css. 10 if ( settings.post_meta['blogreach_custom_mark'] ) { 11 var selectors = document.querySelectorAll( settings.options['blogreach_positions_after_css_selector'] ); 12 for ( var i = 0; i < selectors.length; i++ ) { 13 selectors[i].innerHTML += mark; 14 } 15 } 16 17 // Add the legend direct after the mark. 18 if ( settings.options['blogreach_positions_after_mark'] ) { 19 var selectors = document.querySelectorAll( settings.options['blogreach_positions_after_css_selector'] ); 20 for ( var i = 0; i < selectors.length; i++ ) { 21 selectors[i].innerHTML += legend; 22 } 23 } 24 } 25 } 26 }, false ); 27} 28 29// Set the links to nofollow. 30var nofollow_domains = []; 31function setlinkrel() { 32 window.addEventListener( 'load', function() { 33 var links = document.getElementsByTagName( 'a' ); 34 var domains = settings.options['blogreach_nofollow_domains']; 35 var noreferrer = settings.options['blogreach_noreferrer']; 36 37 // Identify the current link rel. 38 function identifyrel() { 39 if ( links[i].hasAttribute( 'rel' ) ) { 40 // Remove the rel noreferrer attribute if wanted. 41 if ( noreferrer === 'blogreach_noreferrer' ) { 42 if ( links[i].attributes.rel.value.search( /noreferrer/i ) !== -1 ) { 43 links[i].setAttribute( 'rel', links[i].getAttribute( 'rel' ).replace( /noreferrer/i, '' ) ); 44 } 45 } 46 47 // Only when nofollow exists in rel attributes. 48 if ( links[i].attributes.rel.value.search( /nofollow/i ) !== -1 ) { 49 return links[i].getAttribute( 'rel' ).trim(); 50 } 51 52 // Return the existing rel attributes and add nofollow to it. 53 return links[i].getAttribute( 'rel' ).trim() + ' nofollow'; 54 } 55 // If no rel attribute exists, return it and create it than. 56 else { return 'nofollow'; } 57 } 58 59 // Loop through all links. 60 for ( var i = 0; i < links.length; i++ ) { 61 // Mark all external links with rel nofollow if the star selector is activated. 62 if ( domains.includes( '*' ) ) { 63 64 // Set the rel attribute only for externel links. 65 if ( links[i].hostname.includes( window.location.hostname ) !== true ) { 66 links[i].setAttribute( 'rel', identifyrel() ); 67 window.nofollow_domains.push( links[i] ); 68 } 69 } 70 71 // Other set the specific domain as rel nofollow. 72 else if ( domains.indexOf( links[i].hostname ) !== -1 ) { 73 links[i].setAttribute( 'rel', identifyrel() ); 74 window.nofollow_domains.push( links[i] ); 75 } 76 } 77 }, false ); 78} 79 80// Add the link label to affiliate links based on there tags. 81var link_labeling_links = []; 82function setaffiliatelinks() { 83 window.addEventListener( 'load', function() { 84 var links = document.getElementsByTagName( 'a' ); 85 var aff_tags = settings.options['blogreach_link_labeling'].split (', '); 86 for ( var i = 0; i < links.length; i++ ) { 87 for ( var x = 0; x < aff_tags.length; x++ ) { 88 if ( links[i].href.indexOf( aff_tags[x] ) != -1 ) { 89 links[i].innerHTML += '<span class="blogreachlabel">' + settings.options['blogreach_link_label'] + '</span>'; 90 window.link_labeling_links.push( links[i] ); 91 } 92 } 93 } 94 }, false ); 95} 96 97// Support mode function. 98function supportmode() { 99 window.addEventListener( 'load', function() { 100 console.log( 'Blogreach options:' ); 101 console.log( settings.options ); 102 console.log( 'Nofollow domains:' ); 103 console.log( window.nofollow_domains ); 104 console.log( 'Link labeling links:' ); 105 console.log( window.link_labeling_links ); 106 console.log( 'Blogreach post meta:' ); 107 console.log( settings.post_meta ); 108 console.log( 'Blogreach labeling metas:' ); 109 console.log( settings.posts_labeled ); 110 }, false ); 111}
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.