Character.AI Text Color

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

当前为 2023-06-14 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Character.AI Text Color
// @namespace   Character.AI Text Color by Vishanka
// @match       https://*.character.ai/c*
// @grant       none
// @license     MIT
// @version     1.1
// @author      Vishanka via chatGPT
// @description Changes the color of all text except the text within "Quotation Marks"
// @icon        https://i.imgur.com/ynjBqKW.png
// ==/UserScript==

(function() {
  var css = "p { color: #958C7F !important; }";

  var head = document.getElementsByTagName("head")[0];
  var style = document.createElement("style");
  style.setAttribute("type", 'text/css');
  style.innerHTML = css;
  head.appendChild(style);
})();

function changeColors() {
  const pTags = document.getElementsByTagName('p');
  for (let i = 0; i < pTags.length; i++) {
    const pTag = pTags[i];
    if (pTag.dataset.colorChanged === 'true' || pTag.querySelector('code')) {
      continue;
    }
    let text = pTag.innerHTML;
    if (text.match(/(["“”«»].*?["“”«»])/)) {
      text = text.replace(/(["“”«»].*?["“”«»])/g, '<span style="color: #FFFFFF">$1</span>');
    }
if (text.match(/<em>(.*?)<\/em>/)) {
  text = text.replace(/<em>(.*?)<\/em>/g, '<span style="color: #EDB72C; font-style: italic;">$1</span>');
}

    pTag.innerHTML = text;
    pTag.dataset.colorChanged = 'true';
  }
  console.log('Changed colors');
}

// Observe changes in the document and call changeColors() whenever mutations occur
const observer = new MutationObserver(changeColors);
observer.observe(document, { subtree: true, childList: true });

// Initially apply the color changes
changeColors();