LitCharts unblur, allow selection, add links

Unblur and allow text selection in blurred fields, add links to characters, themes, and symbols, remove LitCharts A+ ads

  1. // ==UserScript==
  2. // @name LitCharts unblur, allow selection, add links
  3. // @namespace Violentmonkey Scripts
  4. // @match https://www.litcharts.com/*
  5. // @grant none
  6. // @version 1.3
  7. // @author CyrilSLi
  8. // @description Unblur and allow text selection in blurred fields, add links to characters, themes, and symbols, remove LitCharts A+ ads
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. const classes = ["blurred", "blurred-text", "blur"];
  13. const unblurRetry = setInterval(removeBlur, 10);
  14. const styles = [
  15. "-webkit-touch-callout",
  16. "-webkit-user-select",
  17. "-khtml-user-select",
  18. "-moz-user-select",
  19. "-ms-user-select",
  20. "user-select"
  21. ];
  22. const styleStr = "-webkit-touch-callout:default !important; -webkit-user-select:auto !important; -khtml-user-select:auto !important; -moz-user-select:auto !important; -ms-user-select:auto !important; user-select:auto !important;";
  23.  
  24. var charSymbolLinks = {};
  25. var themeLinks = {};
  26.  
  27. function removeBlur() {
  28. var allElements = [];
  29. for (var i = 0; i < classes.length; i++) {
  30. var blurred = document.getElementsByClassName(classes[i]);
  31. allElements.push(...blurred);
  32. for (var j = 0; j < blurred.length; j++) {
  33. blurred[j].classList.remove(classes[i]);
  34. }
  35. }
  36. if (!allElements.length) {
  37. clearInterval(unblurRetry);
  38. console.log("Finished unblurring");
  39. allowSelect();
  40. }
  41. }
  42.  
  43. function allowSelect() {
  44. var walker = document.createTreeWalker(
  45. document.documentElement,
  46. NodeFilter.SHOW_ELEMENT,
  47. el => {
  48. for (var i = 0; i < styles.length; i++) {
  49. if (getComputedStyle(el)[styles[i]] == "none") {
  50. return NodeFilter.FILTER_ACCEPT;
  51. }
  52. }
  53. return NodeFilter.FILTER_SKIP;
  54. }
  55. );
  56. var els = [];
  57. while (walker.nextNode()) {
  58. walker.currentNode.setAttribute("style", styleStr);
  59. els.push(walker.currentNode);
  60. }
  61. for (var i = 0; i < els.length; i++) {
  62. els[i].parentNode.replaceChild(els[i].cloneNode(true), els[i]);
  63. }
  64. console.log("Allowed selection");
  65. addLinks();
  66. }
  67.  
  68. function addLinks() {
  69. // intentional misspelling of symbol as the website does the same
  70. [...document.querySelectorAll(".dropdown.characters > ul > li > a, .dropdown.simbols > ul > li > a")].forEach((el) => {
  71. charSymName = el.textContent.trim();
  72. if (charSymName.toLowerCase() != "all characters" && charSymName.toLowerCase() != "all symbols") {
  73. charSymbolLinks[charSymName] = el.href;
  74. }
  75. });
  76. [...document.querySelectorAll(".dropdown.themes > ul > li > a")].forEach((el) => {
  77. themeName = el.textContent.trim();
  78. if (themeName.toLowerCase() != "all themes") {
  79. themeLinks[themeName] = el.href;
  80. }
  81. });
  82. [...document.querySelectorAll("span.faux-link")].forEach((el) => {
  83. charSymName = el.textContent.trim();
  84. if (charSymName in charSymbolLinks) {
  85. linkEl = document.createElement("a");
  86. linkEl.textContent = el.textContent;
  87. linkEl.href = charSymbolLinks[charSymName];
  88. el.replaceWith(linkEl);
  89. }
  90. });
  91. [...document.querySelectorAll("div.theme-icon.medium")].forEach((el) => {
  92. el.parentNode.innerHTML = el.parentNode.innerHTML.trim().replace(/^<div/, "<a").replace(/\/div>$/, "/a>");
  93. });
  94. [...document.querySelectorAll("a.theme-icon.medium > img")].forEach((el) => {
  95. themeName = Object.keys(themeLinks).find((theme) => el.alt.includes(theme));
  96. if (themeName != undefined) {
  97. el.parentNode.href = themeLinks[themeName];
  98. el.title = themeName;
  99. }
  100. el.style.visibility = null;
  101. el.src = el.src.replace("litcharts.prod.litcharts.com/icons/", "assets.litcharts.com/icons/");
  102. });
  103. console.log("Added links");
  104. removeAds();
  105. }
  106.  
  107. function removeAds() {
  108. ["analysis-dialog", "analysis-text-dialog", "stretch-left-promo"].forEach((cls) => {
  109. [...document.getElementsByClassName(cls)].forEach((el) => el.remove());
  110. });
  111. console.log("Removed A+ Ads");
  112. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址