ehx link color

change link color

  1. // ==UserScript==
  2. // @name ehx link color
  3. // @namespace https://github.com/x94fujo6rpg/SomeTampermonkeyScripts
  4. // @version 0.27
  5. // @description change link color
  6. // @author x94fujo6
  7. // @match https://e-hentai.org/*
  8. // @match https://exhentai.org/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14. // (use any valid CSS color you want)
  15. // unvisited link color
  16. let enable_link = true;
  17. let ex = "DeepPink";
  18. let eh = "DeepPink";
  19. // visited link color
  20. let enable_visited = true;
  21. let ex_v = "gray";
  22. let eh_v = "gray";
  23. // because of the security risk, visited link color many not work in some browser
  24. // see https://dbaron.org/mozilla/visited-privacy
  25.  
  26. let domain;
  27. window.onload = setlinkcolor();
  28.  
  29. function setlinkcolor() {
  30. domain = getdomain();
  31. if (domain) setcss();
  32. }
  33.  
  34. function setcss() {
  35. let link = document.location.href;
  36. let color = (link.indexOf("exhentai") != -1) ? ex : eh;
  37. let color_v = (link.indexOf("exhentai") != -1) ? ex_v : eh_v;
  38. let style = document.createElement("style");
  39. document.head.appendChild(style);
  40. let csslist = [];
  41. if (enable_link) csslist.push(`
  42. a:link {
  43. color: ${color};
  44. }
  45. `);
  46. if (enable_visited) csslist.push(`
  47. a:visited .glink, a:active .glink {
  48. color:${color_v} !important;
  49. }
  50. `);
  51. myCss(csslist);
  52. }
  53.  
  54. function getdomain() {
  55. let eh = "e-hentai.org";
  56. let ex = "exhentai.org";
  57. let link = document.location.href;
  58. if (link.indexOf("exhentai") != -1) {
  59. return ex;
  60. } else if (link.indexOf("e-hentai") != -1) {
  61. return eh;
  62. }
  63. return false;
  64. }
  65.  
  66. function myCss(innerlist = []) {
  67. if (innerlist.length > 0) {
  68. let s = document.createElement("style");
  69. s.id = "mycss";
  70. document.head.appendChild(s);
  71. let content = "";
  72. innerlist.forEach(inner => content += inner);
  73. s.innerHTML = content;
  74. }
  75. }
  76. })();