Skip to content

Commit

Permalink
Merge pull request #5 from lucalewin/bing-chat-font-color
Browse files Browse the repository at this point in the history
Fix color of Bing Chat
  • Loading branch information
lucalewin authored Mar 26, 2023
2 parents 2d12592 + 535fce3 commit 97e1e98
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packed/*
42 changes: 41 additions & 1 deletion content.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,56 @@ const message_group_callback = (mutationList, observer) => {
if (mutation.type === "childList") {
for (let node of mutation.addedNodes) {
if (node.tagName == "CIB-MESSAGE-GROUP") {
let messageGroup = node.shadowRoot;
let stylesheet = document.createElement("style");
stylesheet.innerHTML =
`
cib-message[type='text'] {
background-color: #333 !important;
}
`;
node.shadowRoot.appendChild(stylesheet);
messageGroup.appendChild(stylesheet);

// change color of text
// only if the message group is from the bot
new MutationObserver(cib_message_callback).observe(messageGroup, config);
}
}
}
}
}

function cib_message_callback(mutationList, observer) {
for (const mutation of mutationList) {
if (mutation.type === "childList") {
for (let node of mutation.addedNodes) {
if (node.tagName == "CIB-MESSAGE") {
if (node.getAttribute("type") == "text") {
let cibMessage = node.shadowRoot;

new MutationObserver((mutationList1, observer1) => {
for (const mutation of mutationList1) {
if (mutation.type == "childList" || mutation.type == "subtree") {
for (let node of mutation.addedNodes) {
if (node.tagName == "STYLE") {
return;
}
}
injectStyleNodeIntoMessageDiv(cibMessage);
}
}
}).observe(cibMessage, config);
}
}
}
}
}
}

function injectStyleNodeIntoMessageDiv(messageDiv) {
let style = document.createElement("style");
style.innerHTML = '*:not(sup) { color: #dadada !important; }';

let textBlock = messageDiv.querySelector(".ac-textBlock");
textBlock.appendChild(style);
}

0 comments on commit 97e1e98

Please sign in to comment.