Character.AI Text Color

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

当前为 2023-10-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Character.AI Text Color
  3. // @namespace Character.AI Text Color by Vishanka
  4. // @match https://*.character.ai/*
  5. // @grant none
  6. // @license MIT
  7. // @version 1.5
  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, .swiper-no-swiping div { color: #958C7F !important; font-family: 'Noto Sans', sans-serif !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 (
  28. pTag.dataset.colorChanged === 'true' ||
  29. pTag.querySelector('code') ||
  30. pTag.querySelector('img')
  31. ) {
  32. continue;
  33. }
  34. let text = pTag.innerHTML;
  35.  
  36. const aTags = pTag.getElementsByTagName('a'); // Get all <a> tags within the <p> tag
  37.  
  38. // Remove the <a> tags temporarily
  39. for (let j = 0; j < aTags.length; j++) {
  40. const aTag = aTags[j];
  41. text = text.replace(aTag.outerHTML, 'REPLACE_ME_' + j); // Use a placeholder to be able to restore the links later
  42. }
  43.  
  44.  
  45. //Changes Text within Quotation Marks to white
  46. if (text.match(/(["“”«»].*?["“”«»])/)) {
  47. text = text.replace(/(["“”«»].*?["“”«»])/g, '<span style="color: #FFFFFF">$1</span>');
  48. }
  49. //Changes Text within Quotation Marks and a comma at the end to orange
  50. if (text.match(/(["“”«»][^"]*?,["“”«»])/)) {
  51. text = text.replace(/(["“”«»][^"]*?,["“”«»])/g, '<span style="color: #E0DF7F">$1</span>');
  52. }
  53. //Changes Italic Text to gold
  54. if (text.match(/<em>(.*?)<\/em>/)) {
  55. text = text.replace(/<em>(.*?)<\/em>/g, '<span style="color: #E0DF7F; font-style: italic;">$1</span>');
  56. }
  57. if (text.match(/(seems)/)) {
  58. text = text.replace(/(seems)/g, '<span style="color: #E0DF7F">$1</span>');
  59. }
  60. if (text.match(/(seem)/)) {
  61. text = text.replace(/(seem)/g, '<span style="color: #E0DF7F">$1</span>');
  62. }
  63.  
  64. // Restore the <a> tags
  65. for (let j = 0; j < aTags.length; j++) {
  66. const aTag = aTags[j];
  67. text = text.replace('REPLACE_ME_' + j, aTag.outerHTML);
  68. }
  69.  
  70. pTag.innerHTML = text;
  71. pTag.dataset.colorChanged = 'true';
  72. }
  73.  
  74.  
  75.  
  76. console.log('Changed colors');
  77. }
  78.  
  79. // Observe changes in the document and call changeColors() whenever mutations occur
  80. const observer = new MutationObserver(changeColors);
  81. observer.observe(document, { subtree: true, childList: true });
  82.  
  83. // Initially apply the color changes
  84. changeColors();

QingJ © 2025

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