Skip to content

Commit

Permalink
Merge branch 'experimental'
Browse files Browse the repository at this point in the history
  • Loading branch information
Elaina69 committed Dec 11, 2024
2 parents 254686d + 1db5a5c commit 9b119a8
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 105 deletions.
48 changes: 0 additions & 48 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
// 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');
Expand Down
68 changes: 68 additions & 0 deletions src/src/plugins/hideFriendlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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
Expand Down
54 changes: 20 additions & 34 deletions src/src/services/backupAndRestoreDatastore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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") }
catch { error("Can not restore datastore") }

window.restoreDefaultDataStore = restoreDefaultDataStore
Loading

0 comments on commit 9b119a8

Please sign in to comment.