211 lines
7.5 KiB
JavaScript
211 lines
7.5 KiB
JavaScript
// Easter Eggs for RosterHash
|
|
// Date-based theme modifications
|
|
|
|
class EasterEggs {
|
|
constructor() {
|
|
this.today = new Date();
|
|
this.month = this.today.getMonth() + 1; // 1-12
|
|
this.day = this.today.getDate();
|
|
}
|
|
|
|
// Check if today is Thanksgiving (4th Thursday of November)
|
|
isThanksgiving() {
|
|
if (this.month !== 11) return false; // Not November
|
|
|
|
const year = this.today.getFullYear();
|
|
let thursdayCount = 0;
|
|
|
|
// Count Thursdays in November
|
|
for (let day = 1; day <= 30; day++) {
|
|
const date = new Date(year, 10, day); // Month 10 = November
|
|
if (date.getDay() === 4) { // Thursday
|
|
thursdayCount++;
|
|
if (thursdayCount === 4 && day === this.day) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// Check if today is April Fools' Day
|
|
isAprilFools() {
|
|
return this.month === 4 && this.day === 1;
|
|
}
|
|
|
|
// Get April Fools team name
|
|
getAprilFoolsTeamName(abbrev) {
|
|
const jokeNames = {
|
|
'SF': '40-Whiners',
|
|
'LAR': 'Lambs',
|
|
'LAC': '🔋 Low Battery',
|
|
'KC': 'Chefs',
|
|
'BUF': 'Buffalo Wild Wings',
|
|
'NE': 'Cheaters',
|
|
'NYJ': 'Just End The Season',
|
|
'NYG': 'Littles',
|
|
'DAL': 'America\'s Team (lol)',
|
|
'PHI': 'Iggles',
|
|
'WAS': 'Commies',
|
|
'GB': 'Cheese Heads',
|
|
'CHI': 'Da Burrs',
|
|
'MIN': 'Purple People Eaters',
|
|
'DET': 'Kitties',
|
|
'TB': 'Tompa Bay',
|
|
'NO': 'Ain\'ts',
|
|
'ATL': 'Dirty Birds',
|
|
'CAR': 'Kittens',
|
|
'ARI': 'Birdinals',
|
|
'SEA': 'Rain City Bird Brains',
|
|
'PIT': 'Stealers',
|
|
'BAL': 'Purple Birds',
|
|
'CLE': 'Factory of Sadness',
|
|
'CIN': 'Bungles',
|
|
'HOU': 'Texas Cows',
|
|
'TEN': 'Tacks',
|
|
'IND': 'Dolts',
|
|
'JAX': 'Jag-wires',
|
|
'LV': 'Traitors',
|
|
'DEN': 'Neigh-bors',
|
|
'MIA': 'Dolphins (but warmer)',
|
|
};
|
|
return jokeNames[abbrev] || abbrev;
|
|
}
|
|
|
|
// Apply Easter eggs
|
|
apply() {
|
|
// Thanksgiving: Replace stars with turkey emoji
|
|
if (this.isThanksgiving()) {
|
|
console.log('🦃 Happy Thanksgiving!');
|
|
this.applyThanksgiving();
|
|
}
|
|
|
|
// April Fools: Replace team names with joke versions
|
|
if (this.isAprilFools()) {
|
|
console.log('🤡 April Fools!');
|
|
this.applyAprilFools();
|
|
}
|
|
}
|
|
|
|
// Apply Thanksgiving theme
|
|
applyThanksgiving() {
|
|
// Replace star emoji in Favorite Teams sidebar section
|
|
const sidebarSummary = document.querySelector('.sidebar-details summary');
|
|
if (sidebarSummary && sidebarSummary.textContent.includes('⭐')) {
|
|
sidebarSummary.innerHTML = sidebarSummary.innerHTML.replace('⭐', '🦃');
|
|
}
|
|
|
|
// Replace star in main Favorite Teams section
|
|
const mainFavoritesTitle = document.querySelector('.favorites-section-main h2');
|
|
if (mainFavoritesTitle && mainFavoritesTitle.textContent.includes('⭐')) {
|
|
mainFavoritesTitle.innerHTML = mainFavoritesTitle.innerHTML.replace('⭐', '🦃');
|
|
}
|
|
|
|
// Add turkey emoji after "Week X Games"
|
|
const scheduleTitle = document.querySelector('.schedule-section h2');
|
|
if (scheduleTitle) {
|
|
const text = scheduleTitle.innerHTML;
|
|
if (!text.includes('🦃')) {
|
|
scheduleTitle.innerHTML = text.replace(/Week (\d+) Games/, 'Week $1 Games 🦃');
|
|
}
|
|
}
|
|
}
|
|
|
|
// Apply April Fools theme
|
|
applyAprilFools() {
|
|
// Store reference to this for use in setTimeout
|
|
const self = this;
|
|
|
|
// Wait for favorites to be rendered, then replace team names
|
|
setTimeout(() => {
|
|
// Replace team names in favorite team rows (main dashboard)
|
|
document.querySelectorAll('.favorite-team-name').forEach(el => {
|
|
const originalName = el.textContent.trim();
|
|
// Try to find the abbreviation from TEAM_NAMES
|
|
let abbrev = null;
|
|
for (const [key, value] of Object.entries(TEAM_NAMES)) {
|
|
if (value === originalName) {
|
|
abbrev = key;
|
|
break;
|
|
}
|
|
}
|
|
if (abbrev) {
|
|
el.textContent = self.getAprilFoolsTeamName(abbrev);
|
|
el.style.fontFamily = '"Comic Sans MS", "Comic Sans", cursive';
|
|
}
|
|
});
|
|
|
|
// Replace opponent names
|
|
document.querySelectorAll('.favorite-opponent').forEach(el => {
|
|
const text = el.textContent.trim();
|
|
const match = text.match(/^(vs|@) (.+)$/);
|
|
if (match) {
|
|
const prefix = match[1];
|
|
const opponentName = match[2];
|
|
|
|
// Find abbreviation
|
|
let abbrev = null;
|
|
for (const [key, value] of Object.entries(TEAM_NAMES)) {
|
|
if (value === opponentName) {
|
|
abbrev = key;
|
|
break;
|
|
}
|
|
}
|
|
if (abbrev) {
|
|
el.textContent = `${prefix} ${self.getAprilFoolsTeamName(abbrev)}`;
|
|
el.style.fontFamily = '"Comic Sans MS", "Comic Sans", cursive';
|
|
}
|
|
}
|
|
});
|
|
|
|
// Replace team names in sidebar favorites list
|
|
document.querySelectorAll('.favorite-game-card .favorite-matchup').forEach(el => {
|
|
const originalName = el.textContent.trim();
|
|
let abbrev = null;
|
|
for (const [key, value] of Object.entries(TEAM_NAMES)) {
|
|
if (value === originalName) {
|
|
abbrev = key;
|
|
break;
|
|
}
|
|
}
|
|
if (abbrev) {
|
|
el.textContent = self.getAprilFoolsTeamName(abbrev);
|
|
el.style.fontFamily = '"Comic Sans MS", "Comic Sans", cursive';
|
|
}
|
|
});
|
|
|
|
// Add April Fools indicator
|
|
const header = document.querySelector('.dashboard-header h1');
|
|
if (header && !header.textContent.includes('🤡')) {
|
|
header.innerHTML += ' <span style="font-size: 0.8em;">🤡</span>';
|
|
}
|
|
}, 500); // Wait for favorites to render
|
|
}
|
|
}
|
|
|
|
// Initialize and apply Easter eggs when DOM is ready
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const easterEggs = new EasterEggs();
|
|
easterEggs.apply();
|
|
|
|
// Re-apply when favorites are updated (listen for changes)
|
|
const observer = new MutationObserver(() => {
|
|
if (easterEggs.isThanksgiving()) {
|
|
easterEggs.applyThanksgiving();
|
|
}
|
|
if (easterEggs.isAprilFools()) {
|
|
easterEggs.applyAprilFools();
|
|
}
|
|
});
|
|
|
|
// Observe favorites sections for changes
|
|
const favoritesDisplay = document.getElementById('favorites-display');
|
|
const favoritesList = document.getElementById('favorites-list');
|
|
|
|
if (favoritesDisplay) {
|
|
observer.observe(favoritesDisplay, { childList: true, subtree: true });
|
|
}
|
|
if (favoritesList) {
|
|
observer.observe(favoritesList, { childList: true, subtree: true });
|
|
}
|
|
});
|