Visited Links Highlighter

let you know if the link is clicked before

  1. // ==UserScript==
  2. // @name Visited Links Highlighter
  3. // @namespace https://jirehlov.com
  4. // @version 0.1.2
  5. // @description let you know if the link is clicked before
  6. // @author Jirehlov
  7. // @match https://bgm.tv/*
  8. // @match https://chii.in/*
  9. // @match https://bangumi.tv/*
  10. // @license MIT
  11. // ==/UserScript==
  12. (() => {
  13. "use strict";
  14. const visitedLinks = JSON.parse(localStorage.getItem("JvCSS")) || {};
  15. const links = document.getElementsByTagName("a");
  16. for (let link of links) {
  17. const href = link.href;
  18. const linkColor = window.getComputedStyle(link).color;
  19. if ((linkColor === "rgb(46, 166, 255)" || linkColor === "rgb(0, 132, 180)") && !link.querySelector("span") && href !== "javascript:void(0);") {
  20. if (visitedLinks[href]) {
  21. link.style.color = "#c58af9";
  22. } else {
  23. link.addEventListener("click", function (event) {
  24. visitedLinks[this.href] = true;
  25. localStorage.setItem("JvCSS", JSON.stringify(visitedLinks));
  26. });
  27. }
  28. }
  29. }
  30. })();