LitCharts unblur & allow selection

Unblur and allow user selection of the blurred fields on LitCharts pages

  1. // ==UserScript==
  2. // @name LitCharts unblur & allow selection
  3. // @namespace Violentmonkey Scripts
  4. // @match https://www.litcharts.com/*
  5. // @grant none
  6. // @version 1.0
  7. // @author CyrilSLi
  8. // @description Unblur and allow user selection of the blurred fields on LitCharts pages
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. const classes = ["blurred", "blurred-text", "blur"];
  13. const unblurRetry = setInterval(removeBlur, 100);
  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. function removeBlur() {
  25. var allElements = [];
  26. for (var i = 0; i < classes.length; i++) {
  27. var blurred = document.getElementsByClassName(classes[i]);
  28. allElements.push(...blurred);
  29. for (var j = 0; j < blurred.length; j++) {
  30. blurred[j].classList.remove(classes[i]);
  31. }
  32. }
  33. if (!allElements.length) {
  34. clearInterval(unblurRetry);
  35. console.log("Finished unblurring elements");
  36. allowSelect();
  37. }
  38. }
  39.  
  40. function allowSelect() {
  41. var walker = document.createTreeWalker(
  42. document.documentElement,
  43. NodeFilter.SHOW_ELEMENT,
  44. el => {
  45. for (var i = 0; i < styles.length; i++) {
  46. if (getComputedStyle(el)[styles[i]] == "none") {
  47. return NodeFilter.FILTER_ACCEPT;
  48. }
  49. }
  50. return NodeFilter.FILTER_SKIP;
  51. }
  52. );
  53. var els = [];
  54. while (walker.nextNode()) {
  55. walker.currentNode.setAttribute("style", styleStr);
  56. els.push(walker.currentNode);
  57. }
  58. for (var i = 0; i < els.length; i++) {
  59. els[i].parentNode.replaceChild(els[i].cloneNode(true), els[i]);
  60. }
  61. console.log("Allowed selection on all elements");
  62. }