Darkening previously clicked-on links in my app

I am creating a search-engine-type application. When someone clicks on a link on the search results page, I want that link to be darkened for subsequent searches, so they don’t accidentally click on the same link again. (I am currently embedding the links in a button-type element, with just the anchor text shown on the front-end, so I can format the color conditionally.)

I suspect I would need to do this by using cookies. Could someone please give me a step-by-step plan on how I can tackle this? I haven’t used cookies for something like this before, so I’m not sure how to read from and write to cookies to implement this.

Yes, you can use a plugin Local Storage & Cookies or any other plugin , store the visited link as text in an arry in cookiers, then on each link add a condition if this text is in that list if so change text colour.

1 Like

Hi @Baloshi69
Thanks, it has almost worked.
I have 3 links per result and 10 results per page. When a link is clicked, I write to localStorage, but I need to also load localStorage whenever the page is loaded, right?

How do I handle the syntax while loading, given that I need to load 3 x 10 links, assuming the links are called link1, link2, and link3?

Arent the localStorage is persistant , cookies can be store for longer time ? … also if your ok you use bubble database to store visited link, for 1 week , then auto remove it, but this will cost workunit

I mean, I’m having difficulty with the syntax.

My main problem is that it is overwriting the data. I want to write a value for a key in such a way that it adds to the existing values. And when I load the data, I want to get all the values for the key.

For example:
key=clickedLinks
value= www.example1.com, www.example2.com

Currently, it is overwriting example1.com with example2.com so that I lose example1.com when example2.com is clicked.