// Get all the links on the page
var links = document.querySelectorAll('a');
// Get the current page's hostname
var currentHostname = window.location.hostname;
// Loop through each link
for (var i = 0; i < links.length; i++) {
var link = links[i];
// Get the hostname of the link
var linkHostname = link.hostname;
// Check if the link is internal or external
if (linkHostname === currentHostname) {
// Internal link - set it as dofollow
link.setAttribute('rel', 'dofollow');
} else {
// External link - set it as nofollow
link.setAttribute('rel', 'nofollow');
}
}
]]>
0 Comments