From 17e6e4f0d7fc1f03f2f21e687b0ab09ee631c958 Mon Sep 17 00:00:00 2001 From: Elaina Da Catto Date: Wed, 11 Dec 2024 14:33:57 +0700 Subject: [PATCH 1/5] Updade: remove old PluginFS code --- src/index.ts | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/src/index.ts b/src/index.ts index f1f5164..8c2e16d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -43,54 +43,6 @@ import { HideFriendList } from './src/plugins/hideFriendlist.ts'; import { ForceJungLane } from "./src/plugins/forceJungleLane.ts" import "./src/plugins/debug.ts" -// Refresh theme's wallpaper list -// const FILE_REGEX: {Wallpaper: RegExp, Audio: RegExp, Font: RegExp, Banner: RegExp} = { -// Wallpaper: /\.(png|jpg|jpeg|gif|bmp|webp|ico|mp4|webm|mkv|mov|avi|wmv|3gp|m4v)$/, -// Audio: /\.(mp3|flac|ogg|wav|aac)$/, -// Font: /\.(ttf|otf|woff|woff2)$/, -// Banner: /\.(png|jpg|jpeg|gif|bmp|webp|ico)$/, -// }; - -// const ASSET_PATHS: {Wallpaper: string, Audio: string, Font: string, Banner: string} = { -// Wallpaper: "./src/assets/backgrounds/wallpapers", -// Audio: "./src/assets/backgrounds/audio", -// Font: "./src/assets/fonts", -// Banner: "./src/assets/icon/regalia-banners", -// }; - -// const refreshBackgroundsList = async (): Promise => { -// try { -// const lists: Object = await Promise.all( -// Object.values(ASSET_PATHS).map((path: string) => window.PluginFS.ls(path)) -// ); - -// const filteredLists: Object = Object.keys(ASSET_PATHS).reduce((acc: Object, key: string, index: number) => { -// acc[key] = lists[index].filter((file: any) => FILE_REGEX[key].test(file)); -// return acc; -// }, {}); - -// Object.entries(filteredLists).forEach(([key, value]) => { -// window.DataStore.set(`${key}-list`, value); -// }); - -// window.DataStore.set("video-2nd-loop", false); -// log('Updated DataStore with lists'); -// } catch (err: any) { -// error('Error refreshing backgrounds list:', err); -// window.DataStore.set("manual-add-background", true); -// } -// }; - -// log('Refreshing backgrounds list'); - -// const backgroundListInterval = setInterval(async () => { -// await refreshBackgroundsList(); -// if (document.getElementById("elaina-bg")) { -// clearInterval(backgroundListInterval); -// log('Stopped reloading list'); -// } -// }, 1000); - class ElainaTheme { init(context: any) { log('Initializing theme'); From 628e4b0c01567e0108c0f4388252920d03f28230 Mon Sep 17 00:00:00 2001 From: Elaina Da Catto Date: Wed, 11 Dec 2024 14:34:20 +0700 Subject: [PATCH 2/5] Update: Change lobby viewpoint to center when hiding friendlist --- src/src/plugins/hideFriendlist.ts | 68 +++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/src/plugins/hideFriendlist.ts b/src/src/plugins/hideFriendlist.ts index 3bd3f47..299234b 100644 --- a/src/src/plugins/hideFriendlist.ts +++ b/src/src/plugins/hideFriendlist.ts @@ -80,6 +80,7 @@ export class HideFriendList { if (!hide) { friendList.style.display = "flex" + this.centerViewport(hide) if (!window.DataStore.get("sidebar-transparent")) { try { document.querySelector("#sideBarColor-hideFriendslist")?.remove() @@ -89,6 +90,7 @@ export class HideFriendList { } else { friendList.style.display = "none" + this.centerViewport(hide) if (!window.DataStore.get("sidebar-transparent")) { try { document.querySelector("#sideBarColor-hideFriendslist")?.remove() @@ -98,6 +100,72 @@ export class HideFriendList { } } + centerViewport = (hide: boolean) => { + if (!hide) { + try { + document.querySelector("#centerViewport")?.remove(); + } catch {} + utils.addStyleWithID("centerViewport", ` + .parties-game-type-select-wrapper.ember-view { + left: 0px ; + } + .parties-custom-game-setup.ember-view { + position: relative; left: 0px ; + } + .custom-game-list.ember-view { + position: relative; + left: 0px ; + } + .parties-lower-section { + position: relative; + left: 0px ; + } + .v2-footer-component.ember-view { + left: 0px; + } + .invite-info-panel-container { + display: flex !important; + } + .arrow-footer.ember-view > div { + position: relative; + left: 0px; + } + `) + } + else { + try { + document.querySelector("#centerViewport")?.remove(); + } catch {} + utils.addStyleWithID("centerViewport", ` + .parties-game-type-select-wrapper.ember-view { + left: 113px; + } + .v2-footer-component.ember-view { + left: 113px; + } + .parties-custom-game-setup.ember-view { + position: relative; + left: 113px ; + } + .custom-game-list.ember-view { + position: relative; + left: 113px ; + } + .parties-lower-section { + position: relative; + left: 113px ; + } + .arrow-footer.ember-view > div { + position: relative; + left: 113px; + } + .invite-info-panel-container { + display: none !important; + } + `) + } + } + main = () => { upl.observer.subscribeToElementCreation(".actions-bar > .buttons", (element: any) => { if (document.querySelector(".hideFriendslist")) return From 4ada7293a265be76a4027593c03918a42a679b01 Mon Sep 17 00:00:00 2001 From: Elaina Da Catto Date: Wed, 11 Dec 2024 14:34:56 +0700 Subject: [PATCH 3/5] Fix: Restore data message --- src/src/services/backupAndRestoreDatastore.ts | 54 +++++++------------ 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/src/src/services/backupAndRestoreDatastore.ts b/src/src/services/backupAndRestoreDatastore.ts index 683bf55..df3a466 100644 --- a/src/src/services/backupAndRestoreDatastore.ts +++ b/src/src/services/backupAndRestoreDatastore.ts @@ -56,7 +56,7 @@ export class BackupRestoreData { }) } - restore = async () => { + restore = async (force: boolean = false) => { let datastore_list: Object = window.DataStore.get("Dev-mode") ? (await this.importData(`//plugins/${getThemeName()}/elaina-theme-data/src/config/datastoreDefault.js`)) //@ts-ignore @@ -65,48 +65,34 @@ export class BackupRestoreData { if (window.DataStore.get("Elaina-Plugins")) { this.setDefaultData(datastore_list) } - else if (!window.DataStore.get("Elaina-Plugins") || !window.DataStore.has("Elaina-Plugins")) { - //console.log(eConsole+`%c Finding backup file from cloud...`,eCss,"") - this.setDefaultData(datastore_list) - window.setTimeout(()=> {window.restartClient()}, 5000) - - - // window.setTimeout(() => { - // let restoreData = new Promise((resolve, reject) => { - // setTimeout(async () => { - // resolve() - // try { - // let summonerID = await utils.getSummonerID() - // let cloud = await readBackup(summonerID, "datastore.json") - // if (cloud.success) { - // console.log(eConsole+`%c Found datastore file from cloud, ready to restore it`,eCss,"") - // setDefaultData(JSON.parse(cloud.content), true) - // window.setTimeout(()=>window.restartClient()) - // } - // } - // catch { - // console.log(eConsole+`%c Datastore file not found, use default theme's settings instead`,eCss,"") - // } - // },5000) - // }) - - // Toast.promise(restoreData, { - // loading: 'Restoring Datastore...', - // success: 'Restore complete!', - // error: '' - // }) - // },15000) + else if (!window.DataStore.get("Elaina-Plugins") || !window.DataStore.has("Elaina-Plugins") || force) { + let restoreData = new Promise((resolve: any, reject) => { + this.setDefaultData(datastore_list) + setTimeout(async () => { + resolve() + window.restartClient() + },5000) + }) + + window.Toast.promise(restoreData, { + loading: 'Restoring Datastore...', + success: 'Restore complete!', + error: '' + }) } } } const backupRestoreData = new BackupRestoreData() +const restoreDefaultDataStore = backupRestoreData.restore try { // Restore Datastore file if no theme's data - await backupRestoreData.restore() + await restoreDefaultDataStore() // Backup datastore backupRestoreData.backup() } -catch { error("Can not restore datastore") } \ No newline at end of file +catch { error("Can not restore datastore") } + +window.restoreDefaultDataStore = restoreDefaultDataStore \ No newline at end of file From 5fa0c599d3ac771dd683fcec40235a09eb2905f5 Mon Sep 17 00:00:00 2001 From: Elaina Da Catto Date: Wed, 11 Dec 2024 14:35:25 +0700 Subject: [PATCH 4/5] Fix: Wallpaper/audio load in v14.24 --- src/src/theme/homepage.ts | 65 ++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/src/src/theme/homepage.ts b/src/src/theme/homepage.ts index 280b953..72c8053 100644 --- a/src/src/theme/homepage.ts +++ b/src/src/theme/homepage.ts @@ -24,6 +24,8 @@ window.DataStore.set("Plugin-folder-name", getThemeName()); let previous_page = ''; let runtime = 0; +let addedBackgrounds = false + let debounceTimer: any; const mutationConfig = { @@ -213,7 +215,7 @@ class WallpaperController { elainaBg.playbackRate = window.DataStore.get("Playback-speed") / 100; }; - changeBG = (BG: string) => { + changeBG = async (BG: string) => { const elainaBg: any = document.getElementById("elaina-bg"); const elainaStaticBg: any = document.getElementById("elaina-static-bg"); @@ -225,9 +227,12 @@ class WallpaperController { elainaBg.classList.remove("webm-hidden"); elainaStaticBg.classList.remove("webm-hidden"); }, 500); + + // @ts-ignore + await refreshList() } - nextWallpaper = () => { + nextWallpaper = async() => { const elainaBg: any = document.getElementById("elaina-bg"); elainaBg.classList.add("webm-hidden"); const elainaStaticBg: any = document.getElementById("elaina-static-bg"); @@ -238,10 +243,10 @@ class WallpaperController { window.DataStore.set('wallpaper-index', 0); } - this.changeBG(window.DataStore.get("Wallpaper-list")[window.DataStore.get('wallpaper-index')]); + await this.changeBG(window.DataStore.get("Wallpaper-list")[window.DataStore.get('wallpaper-index')]); }; - prevWallpaper = () => { + prevWallpaper = async() => { const elainaBg: any = document.getElementById("elaina-bg"); elainaBg.classList.add("webm-hidden"); const elainaStaticBg: any = document.getElementById("elaina-static-bg"); @@ -252,7 +257,7 @@ class WallpaperController { window.DataStore.set('wallpaper-index', window.DataStore.get("Wallpaper-list").length - 1); } - this.changeBG(window.DataStore.get("Wallpaper-list")[window.DataStore.get('wallpaper-index')]); + await this.changeBG(window.DataStore.get("Wallpaper-list")[window.DataStore.get('wallpaper-index')]); }; } @@ -311,32 +316,35 @@ class AudioController { audio.src = `${bgFolder}audio/${song}`; }; - updateAudio = (song) => { + updateAudio = async (song) => { this.loadSong(song); this.audioPlayPause(); this.changeSongName(); log(`Now playing %c${song}`, 'color: #0070ff'); + + // @ts-ignore + await refreshList() } - nextSong = () => { + nextSong = async () => { if (window.DataStore.get("Continues_Audio")) { window.DataStore.set('audio-index', window.DataStore.get('audio-index') + 1); if (window.DataStore.get('audio-index') > window.DataStore.get("Audio-list").length - 1) { window.DataStore.set('audio-index', 0); } - this.updateAudio(window.DataStore.get("Audio-list")[window.DataStore.get('audio-index')]); + await this.updateAudio(window.DataStore.get("Audio-list")[window.DataStore.get('audio-index')]); } }; - prevSong = () => { + prevSong = async () => { if (window.DataStore.get("Continues_Audio")) { window.DataStore.set('audio-index', window.DataStore.get('audio-index') - 1); if (window.DataStore.get('audio-index') < 0) { window.DataStore.set('audio-index', window.DataStore.get("Audio-list").length - 1); } - this.updateAudio(window.DataStore.get("Audio-list")[window.DataStore.get('audio-index')]); + await this.updateAudio(window.DataStore.get("Audio-list")[window.DataStore.get('audio-index')]); } }; @@ -468,7 +476,8 @@ class MainController { wallpaperControls.append(prevBg, pauseBg, nextBg); nextBg.append(nextBgIcon); prevBg.append(prevBgIcon); - } else { + } + else { const newBgChange = document.createElement("div"); newBgChange.id = "newbgchange"; newBgChange.append(bgDropdown); @@ -478,7 +487,7 @@ class MainController { const el = document.createElement("lol-uikit-dropdown-option"); el.setAttribute("slot", "lol-uikit-dropdown-option"); el.innerText = opt; - el.onclick = () => { + el.onclick = async () => { const elainaBg: any = document.getElementById("elaina-bg"); elainaBg.classList.add("webm-hidden"); const elainaStaticBg: any = document.getElementById("elaina-static-bg"); @@ -486,7 +495,7 @@ class MainController { window.DataStore.set('wallpaper-index', id); - wallpaperController.changeBG(window.DataStore.get("Wallpaper-list")[window.DataStore.get('wallpaper-index')]) + await wallpaperController.changeBG(window.DataStore.get("Wallpaper-list")[window.DataStore.get('wallpaper-index')]) }; if (window.DataStore.get('wallpaper-index') === id) { el.setAttribute("selected", "true"); @@ -572,7 +581,7 @@ class MainController { } // Event delegation for dynamically created elements - container.addEventListener('click', (event: any) => { + container.addEventListener('click',async (event: any) => { if (event.target.closest('#pause-audio')) { window.DataStore.set('pause-audio', window.DataStore.get('pause-audio') + 1); audioController.audioPlayPause(); @@ -580,11 +589,11 @@ class MainController { audioController.changeSongName(); } if (event.target.closest('#next-audio')) { - audioController.nextSong(); + await audioController.nextSong(); audioController.changeSongName(); } if (event.target.closest('#prev-audio')) { - audioController.prevSong(); + await audioController.prevSong(); audioController.changeSongName(); } if (event.target.closest('#audio-loop')) { @@ -645,6 +654,10 @@ class WallpaperAndAudio { } setWallpaperElement = () => { + if (window.DataStore.get('wallpaper-index') > window.DataStore.get("Wallpaper-list").length - 1) { + window.DataStore.set('wallpaper-index', 0); + } + const video: any = document.getElementById("elaina-bg") video.autoplay = true; video.volume = window.DataStore.get("wallpaper-volume"); @@ -654,6 +667,10 @@ class WallpaperAndAudio { video.playbackRate = window.DataStore.get("Playback-speed") / 100; video.loop = true; + video.addEventListener('timeupdate', () => { + window.DataStore.set("Wallpaper-currentTime", video.currentTime) + }); + video.addEventListener("error", () => { video.load(); video.addEventListener("ended", () => video.load()); @@ -667,6 +684,10 @@ class WallpaperAndAudio { setAudioElement = () => { if (!window.DataStore.get("Disable-Theme-Audio")) { + if (window.DataStore.get('audio-index') > window.DataStore.get("Audio-list").length - 1) { + window.DataStore.set('audio-index', 0); + } + const audio: any = document.getElementById("bg-audio") audio.autoplay = true; audio.src = `${bgFolder}audio/${window.DataStore.get("Audio-list")[window.DataStore.get('audio-index')]}`; @@ -674,10 +695,17 @@ class WallpaperAndAudio { audio.muted = window.DataStore.get("mute-audio"); audio.currentTime = window.DataStore.get("Audio-currentTime"); + audio.addEventListener('timeupdate', () => { + window.DataStore.set("Audio-currentTime", audio.currentTime) + }); + if (window.DataStore.get('audio-loop')) { audio.addEventListener("ended", () => audio.load()); } - else audio.addEventListener("ended", audioController.nextSong); + else audio.addEventListener("ended", () => { + audioController.nextSong() + audioController.changeSongName() + }); audio.addEventListener("error", () => audio.load()); } @@ -760,7 +788,8 @@ class AddHomePage { const pagename = node.getAttribute("data-screen-name"); const isOtherPage = !["rcp-fe-lol-navigation-screen", "window-controls", "rcp-fe-lol-home", "social"].includes(pagename); - if (pagename === "rcp-fe-lol-navigation-screen") { + if (pagename === "window-controls" && !addedBackgrounds) { + addedBackgrounds = true wallpaperAndAudio.loadWallpaperAndMusic() wallpaperAndAudio.logDebuggingInfo() From 1db5a5cf1b1c51b804caf5c29bac75b00485cf2a Mon Sep 17 00:00:00 2001 From: Elaina Da Catto Date: Wed, 11 Dec 2024 14:35:48 +0700 Subject: [PATCH 5/5] Update: v4.2.6 --- src/src/updates/updateKeyLocal.ts | 2 +- src/types.d.ts | 5 ++-- vite.config.ts | 40 +++++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/src/updates/updateKeyLocal.ts b/src/src/updates/updateKeyLocal.ts index 520b1e5..04773d3 100644 --- a/src/src/updates/updateKeyLocal.ts +++ b/src/src/updates/updateKeyLocal.ts @@ -1 +1 @@ -export default 425 \ No newline at end of file +export default 426 \ No newline at end of file diff --git a/src/types.d.ts b/src/types.d.ts index ac98204..988e155 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -117,11 +117,12 @@ declare interface Window { log : (message: string, ...args: string[]) => void; warn : (message: string, ...args: string[]) => void; error : (message: string, ...args: string[]) => void; - setAudio : () => void; + setAudio : () => void; + restoreDefaultDataStore : () => Promise; storeObserver : any; __llver : string; -} +}; declare function getString(param: string) : Promise; declare function writeBackupData() : void; \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 09e5923..d5b79da 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -127,7 +127,42 @@ export default defineConfig((config) => ({ // Add author comment block const Author = `/**\n* @name ElainaV4\n* @author Elaina Da Catto\n* @description Elaina theme for Pengu Loader\n* @link https://github.com/Elaina69\n* @Nyan Meow~~~\n*/`; - + const importDir = "" +/* +` +import wallpaper from "./assets/backgrounds/wallpapers?dir" +import audio from "./assets/backgrounds/audio?dir" +import font from "./assets/fonts?dir" +import banner from "./assets/icon/regalia-banners?dir" + +const refreshList = async () => { + const FILE_REGEX = { + Wallpaper: /\.(png|jpg|jpeg|gif|bmp|webp|ico|mp4|webm|mkv|mov|avi|wmv|3gp|m4v)$/, + Audio: /\.(mp3|flac|ogg|wav|aac)$/, + Font: /\.(ttf|otf|woff|woff2)$/, + Banner: /\.(png|jpg|jpeg|gif|bmp|webp|ico)$/, + }; + + const dataLists = { + Wallpaper: await wallpaper.files(), + Audio: await audio.files(), + Banner: await banner.files(), + Font: await font.files(), + }; + + const filteredLists = Object.keys(FILE_REGEX).reduce((acc, key) => { + acc[key] = dataLists[key].filter(file => FILE_REGEX[key].test(file)); + return acc; + }, {}); + + Object.entries(filteredLists).forEach(([key, list]) => { + window.DataStore.set(\`\${key}-list\`, list); + }); +} + +await refreshList() +` +*/ async function prependCommentToFile(filePath, commentBlock) { try { if (!existsSync(filePath)) { @@ -138,12 +173,13 @@ export default defineConfig((config) => ({ const data = await readFile(filePath, 'utf-8'); const updatedContent = `${commentBlock.trim()}\n\n${data}`; await writeFile(filePath, updatedContent, 'utf-8'); - console.log(chalk.green('✔ Author name added successfully!')); + //console.log(chalk.green('✔ Author name added successfully!')); } catch (err) { console.error(chalk.red('Error while processing the file:'), err); } } + await prependCommentToFile(indexJs, importDir); await prependCommentToFile(indexJs, Author); // Copy assets and config folders