I'm trying to make a user script that gets the first anchor element that has been visited in javascript but for some reason the querySelector
isn't working with :visited
const element = document.querySelector("a:visited");
element; // => null
I know there are atleast a couple of visited tags because I inspected the page and there were some css styles using a:visited
and those styles were applied, (for example: color: #f5a383;
);
The next thing I tried was to get each <a>
tags and then find the first one that's computed color value was correct
const elements = document.querySelectorAll("a");
let element = [...elements].find(e => getComputedStyle(e).getPropertyValue("color").trim() === "#f5a383");
But this also didn't get the element
Lastly just to make sure it wasn't the website's fault I made a test project and it still failed: