Character.AI Text Color

Changes the color of all text except the text within "Quotation Marks"

当前为 2023-05-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Character.AI Text Color
  3. // @namespace Character.AI Text Color by Vishanka
  4. // @match https://*.character.ai/c*
  5. // @grant none
  6. // @license MIT
  7. // @version 1.0
  8. // @author Vishanka via chatGPT
  9. // @description Changes the color of all text except the text within "Quotation Marks"
  10. // @icon https://i.imgur.com/ynjBqKW.png
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. var css = "p { color: #958C7F !important; }";
  15.  
  16. var head = document.getElementsByTagName("head")[0];
  17. var style = document.createElement("style");
  18. style.setAttribute("type", 'text/css');
  19. style.innerHTML = css;
  20. head.appendChild(style);
  21. })();
  22.  
  23. function changeColors() {
  24. const pTags = document.getElementsByTagName('p');
  25. for (let i = 0; i < pTags.length; i++) {
  26. const pTag = pTags[i];
  27. if (pTag.dataset.colorChanged === 'true') {
  28. continue;
  29. }
  30. let text = pTag.innerHTML;
  31. if (text.match(/(["“”«»].*?["“”«»])/)) {
  32. text = text.replace(/(["“”«»].*?["“”«»])/g, '<span style="color: #FFFFFF">$1</span>');
  33. pTag.innerHTML = text;
  34. pTag.dataset.colorChanged = 'true';
  35. }
  36. }
  37. console.log('Changed colors');
  38. }
  39.  
  40. // Observe changes in the document and call changeColors() whenever mutations occur
  41. const observer = new MutationObserver(changeColors);
  42. observer.observe(document, { subtree: true, childList: true });
  43.  
  44. // Initially apply the color changes
  45. changeColors();