Add back chat buttons with --chat-buttons (#3947)
This commit is contained in:
parent
f5fb1ee666
commit
2ad6ca8874
6 changed files with 61 additions and 33 deletions
44
js/main.js
44
js/main.js
|
@ -249,7 +249,7 @@ for(i = 0; i < noBackgroundelements.length; i++) {
|
|||
// The show/hide events were adapted from:
|
||||
// https://github.com/SillyTavern/SillyTavern/blob/6c8bd06308c69d51e2eb174541792a870a83d2d6/public/script.js
|
||||
//------------------------------------------------
|
||||
const buttonsInChat = document.getElementById("chat-tab").querySelectorAll("button");
|
||||
var buttonsInChat = document.querySelectorAll("#chat-tab #chat-buttons:not(.old-ui) button");
|
||||
var button = document.getElementById('hover-element-button');
|
||||
var menu = document.getElementById('hover-menu');
|
||||
|
||||
|
@ -261,26 +261,34 @@ function hideMenu() {
|
|||
menu.style.display = 'none'; // Hide the menu
|
||||
}
|
||||
|
||||
for (let i = 14; i >= 2; i--) {
|
||||
const thisButton = buttonsInChat[i];
|
||||
menu.appendChild(thisButton);
|
||||
if (buttonsInChat.length > 0) {
|
||||
for (let i = buttonsInChat.length - 1; i >= 0; i--) {
|
||||
const thisButton = buttonsInChat[i];
|
||||
menu.appendChild(thisButton);
|
||||
|
||||
if(i != 10) {
|
||||
thisButton.addEventListener("click", () => {
|
||||
hideMenu();
|
||||
});
|
||||
}
|
||||
if(i != 8) {
|
||||
thisButton.addEventListener("click", () => {
|
||||
hideMenu();
|
||||
});
|
||||
}
|
||||
|
||||
const buttonText = thisButton.textContent;
|
||||
const matches = buttonText.match(/(\(.*?\))/);
|
||||
|
||||
if (matches && matches.length > 1) {
|
||||
// Apply the transparent-substring class to the matched substring
|
||||
const substring = matches[1];
|
||||
const newText = buttonText.replace(substring, ` <span class="transparent-substring">${substring}</span>`);
|
||||
thisButton.innerHTML = newText;
|
||||
}
|
||||
const buttonText = thisButton.textContent;
|
||||
const matches = buttonText.match(/(\(.*?\))/);
|
||||
|
||||
if (matches && matches.length > 1) {
|
||||
// Apply the transparent-substring class to the matched substring
|
||||
const substring = matches[1];
|
||||
const newText = buttonText.replace(substring, ` <span class="transparent-substring">${substring}</span>`);
|
||||
thisButton.innerHTML = newText;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buttonsInChat = document.querySelectorAll("#chat-tab #chat-buttons.old-ui button");
|
||||
console.log(buttonsInChat);
|
||||
for (let i = 0; i < buttonsInChat.length; i++) {
|
||||
buttonsInChat[i].textContent = buttonsInChat[i].textContent.replace(/ \(.*?\)/, '');
|
||||
}
|
||||
document.getElementById('gr-hover').parentElement.style.display = 'none';
|
||||
}
|
||||
|
||||
function isMouseOverButtonOrMenu() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue