sorry for my incredibly slow reply but I’ve only just looked at this
It worked perfectly so thank you very much!
I did the same for a few other affiliates and simply copy and pasted the same code four times, each time replacing the word and it seemed to work just fine
Your code is very long (Anyway no need each time to create <script></script> tag).
Try this Copy - paste before body (Jquery)
<script>
var noFollowArray = [
"amazon",
"ebay",
"airbnb"
];
noFollowArray.forEach(function(element) {
console.log(element);
var noFollowLinks = $('a[href*=' + element +"]")
noFollowLinks.attr('rel', 'nofollow');
});
</script>
Only update noFollowArray array.
Important - remember to add , and "(open) and "(close) for each item/site (Common error). Useful tool for this idea: https://esprima.org/demo/validate.html
Heya
Thank you for this, but it doesn’t seem to have worked. None of these links now have the rel attribute added in the published version of the site.
Here is the complete code:
<script>
var noFollowArray = [
"amazon",
"amzn",
"ebay",
"airbnb",
"booking.com",
"getyourguide",
"viator",
"miaomiao",
"landedvibe",
"hostelworld",
];
noFollowArray.forEach(function(element) {
console.log(element);
var noFollowLinks = $('a[href*=' + element +"]")
noFollowLinks.attr('rel', 'nofollow');
});
</script>
Here is an example page with a number of such links that should now have the rel attribute:
It means the script is working. Source is rendered by the server, JavaScript is rendered on the client. You can’t see client side changes to the source. Only by using the inspector.
I provided a screen shot of the source for the page you provided. The screenshot shows a link to booking.com that has rel=nofollow. I went back and looked right now. It is still there. Maybe you are looking somewhere else?