From c7ce6f1484374f975491fd6246903b2cbef47494 Mon Sep 17 00:00:00 2001 From: Josh Archer Date: Wed, 3 May 2023 23:43:51 -0400 Subject: [PATCH 1/2] Allow themed join/exit button and fix wrap bug --- CharactersPage.js | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/CharactersPage.js b/CharactersPage.js index 354c1c218..737107bc6 100644 --- a/CharactersPage.js +++ b/CharactersPage.js @@ -559,32 +559,26 @@ function inject_join_exit_abovevtt_button() { if ($(".ddbc-campaign-summary").length === 0) return; // we don't have any campaign data if ($("#avtt-character-join-button").length > 0) return; // we already injected a button + $(".ct-character-sheet-desktop > .ct-character-header-desktop").css({display: "inline-flex"}) const desktopPosition = $(".ct-character-sheet-desktop > .ct-character-header-desktop > .ct-character-header-desktop__group--gap"); const tabletPosition = $(".ct-character-sheet-tablet .ct-main-tablet > .ct-main-tablet__campaign"); const mobilePosition = $(".ct-character-sheet-mobile .ct-main-mobile > .ct-main-mobile__campaign"); const buttonText = is_abovevtt_page() ? "Exit AboveVTT" : "Join AboveVTT"; const button = $(`${buttonText}`); + let color = $(".ddbc-campaign-summary").css("border-color") ?? "black"; + button.css({ + "color": "white", + "background": color + }); + button.hover(() => button.css({"filter": "brightness(85%)"}), () => button.css({"filter": "brightness(100%)"})); if (desktopPosition.length > 0) { desktopPosition.append(button); - button.css({ - "color": "white" - }); } else if (tabletPosition.length > 0) { tabletPosition.prepend(button); - if (tabletPosition.hasClass("ct-main-tablet__campaign--dark-mode")) { - button.css({"color": "white", "background": "rgba(16,22,26,.859)"}); - } else { - button.css({"background": "white"}); - } } else if (mobilePosition.length > 0) { mobilePosition.prepend(button); - if (mobilePosition.hasClass("ct-main-mobile__campaign--dark-mode")) { - button.css({"color": "white", "background": "rgba(16,22,26,.859)"}); - } else { - button.css({"background": "white"}); - } } button.click(function(event) { @@ -594,6 +588,26 @@ function inject_join_exit_abovevtt_button() { window.location.href = `${window.location.origin}${window.location.pathname}?abovevtt=true`; } }); + + + var observer = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + console.log("test"); + if (mutation.attributeName == "class") { + // here you can play with it now :) + console.log("test"); + if (mutation.target.classList.contains('.ct-character-header-desktop__button')) { + let button = document.getElementById("avtt-character-join-button"); + let color = $(".ct-character-header-desktop__button")[0].css("border-color") ?? "black"; + button.css({ + "color": "white", + "background": color + }); + } + } + }); + }); + observer.observe($(".ct-character-header-desktop__button").get(0), {attributes: true}); } function inject_join_button_on_character_list_page() { @@ -655,6 +669,13 @@ function observe_character_theme_change() { // console.log("theme_observer is calling find_and_set_player_color", mutation, node); const newColor = node.innerHTML.match(/#(?:[0-9a-fA-F]{3}){1,2}/)?.[0]; if (newColor) { + let button = $("#avtt-character-join-button"); + //$(".ct-character-sheet-desktop > .ct-character-header-desktop > .ct-character-header-desktop__group--gap"); + let color = $(".ct-character-header-desktop__button").css("border-color") ?? "black"; + button.css({ + "color": "white", + "background": color + }); update_window_color(newColor); if(window.PeerManager != undefined) window.PeerManager.send(PeerEvent.preferencesChange()); From 493de9d0fca4165d4cbcd369566d9a2a17b43b17 Mon Sep 17 00:00:00 2001 From: Josh Archer Date: Wed, 3 May 2023 23:48:01 -0400 Subject: [PATCH 2/2] Forgot to remove this --- CharactersPage.js | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/CharactersPage.js b/CharactersPage.js index 737107bc6..d08c07888 100644 --- a/CharactersPage.js +++ b/CharactersPage.js @@ -588,26 +588,6 @@ function inject_join_exit_abovevtt_button() { window.location.href = `${window.location.origin}${window.location.pathname}?abovevtt=true`; } }); - - - var observer = new MutationObserver(function(mutations) { - mutations.forEach(function(mutation) { - console.log("test"); - if (mutation.attributeName == "class") { - // here you can play with it now :) - console.log("test"); - if (mutation.target.classList.contains('.ct-character-header-desktop__button')) { - let button = document.getElementById("avtt-character-join-button"); - let color = $(".ct-character-header-desktop__button")[0].css("border-color") ?? "black"; - button.css({ - "color": "white", - "background": color - }); - } - } - }); - }); - observer.observe($(".ct-character-header-desktop__button").get(0), {attributes: true}); } function inject_join_button_on_character_list_page() {