Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for spamming styles to DOM, Winner Animation Style Change #34

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion entrypoints/match.content/liveViewRing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function liveViewRing() {
.ad-ext_boardview-container .ad-ext_boardview-numbers {
display: block;
}
`);
`, "live-view-ring");

const config = await AutodartsToolsConfig.getValue();
const ringSize = config.liveViewRing.size;
Expand Down
2 changes: 1 addition & 1 deletion entrypoints/match.content/scoreSmaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function scoreSmaller() {
try {
addStyles(`
.adp_points-small { font-size: 3em!important; }
`);
`, "score-smaller");

const activePlayerCardPointsEl = document.querySelector(".ad-ext-player-active .ad-ext-player-score") || document.querySelector(".ad-ext-player-winner .ad-ext-player-score");
const inactivePlayerCardPointsElArr = [ ...document.querySelectorAll(".ad-ext-player-inactive .ad-ext-player-score") ];
Expand Down
8 changes: 7 additions & 1 deletion entrypoints/match.content/winner-animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ export async function winnerAnimation() {
animation: steam 20s linear infinite;
border-radius: 5px;
}

.ad-ext-player-winner + div {
border-radius: 5px;
background: black;
margin-top: 2px;
}

@keyframes steam {
0% {
Expand All @@ -109,7 +115,7 @@ export async function winnerAnimation() {
.ad-ext_winner-animation:after {
filter: blur(50px);
}
`);
`, "winner-animation");

await waitForElement("#ad-ext-turn");

Expand Down
11 changes: 9 additions & 2 deletions utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ export function waitForElementWithTextContent(selector: string | string[], textC
});
}

export function addStyles(css: string) {
/**
* @param css {string} - CSS rules string to be added
* @param componentName {string} - Name of the component
*/
export function addStyles(css: string, componentName: string = "") {
const style = document.createElement("style");
style.id = `ad-ext_style_${componentName}`;
style.innerHTML = css;
document.getElementsByTagName("head")[0].appendChild(style);
if (!document.querySelector(`#${style.id}`)) {
document.head.appendChild(style);
}
}