Plex-Meta-Manager/docs/stylesheets/branch.js

32 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-11-06 20:38:00 +00:00
// custom.js
2023-12-31 17:36:10 +00:00
// Function to check if the current URL contains "nightly" or "develop" and adjust styles accordingly
2023-11-06 20:38:00 +00:00
function checkURLForBranch() {
const currentURL = window.location.href;
2023-12-31 17:36:10 +00:00
// Helper function to update style and text
function updateTheme(headerColor, tabsColor, textContent) {
const header = document.querySelector(".md-header");
const tabs = document.querySelector(".md-tabs");
2023-11-06 20:38:00 +00:00
const ellipsisSpan = document.querySelector(".md-ellipsis");
2023-12-31 17:36:10 +00:00
if (header && tabs) { // Check if elements exist
header.style.backgroundColor = headerColor;
tabs.style.backgroundColor = tabsColor;
2023-11-06 20:38:00 +00:00
}
2023-12-31 17:36:10 +00:00
if (ellipsisSpan) { // Check if element exists
ellipsisSpan.textContent = textContent;
2023-11-06 20:38:00 +00:00
}
}
2023-12-31 17:36:10 +00:00
// Change theme based on URL segment
2023-12-31 17:38:17 +00:00
if (currentURL.includes("en/nightly")) {
2023-12-31 17:36:10 +00:00
updateTheme("#262dbd", "#262dbd", "PMM Nightly Wiki");
2023-12-31 17:38:17 +00:00
} else if (currentURL.includes("en/develop")) {
2023-12-31 17:36:10 +00:00
updateTheme("#ffa724", "#ffa724", "PMM Develop Wiki");
}
}
2023-11-06 20:38:00 +00:00
// Call the function on page load
2023-12-31 17:36:10 +00:00
window.addEventListener("load", checkURLForBranch);