Author Topic: Bookmarklet: highlight links based on URL  (Read 218 times)

ergophobe

  • Inner Core
  • Hero Member
  • *
  • Posts: 7338
    • View Profile
Bookmarklet: highlight links based on URL
« on: November 05, 2021, 03:38:32 AM »
Client wants to update all his affiliate links and direct links to three retailers (I don't know why it's a mix of both). It's going to have to be done manually, but to help he asked me to pull from the DB and identify all the pages with those links. But some of them are long and it occurred to me that his employee who is doing this might waste a lot of time trying to find the links on the page and might miss some.

So I created this little bookmarklet that highlights the direct links to the merchants in yellow and the affiliate links in green. First time I've created a bookmarklet honestly. 10X easier than the next easiest solution I could think of. Here's the unminified version.

Code: [Select]
javascript: (function() {
    for (i = 0; i < document.links.length; i++) {
var url=document.links[i].href;
if (url.includes("backcountry.com") || url.includes("rei.com") || url.includes("moosejaw.com")) {
document.links[i].style.backgroundColor = '#ffff00';
}
if (url.includes("avantlink.com")) {
document.links[i].style.backgroundColor = '#00dd00';
}
}
})();