Started work on optional offial yotuube embed playback. Added basic client settings panel.

This commit is contained in:
rainbow napkin 2025-05-07 01:08:17 -04:00
parent 336c746ba7
commit aadeac03df
8 changed files with 173 additions and 1 deletions

View file

@ -32,6 +32,12 @@ class channel{
this.userList = new userList(this);
//Create the Canopy Panel Object
this.cPanel = new cPanel(this);
//Set defaults for any unset settings and run any required process steps for the current config
this.setDefaults(false, true);
//Freak out any weirdos who take a peek in the dev console for gaffs
console.log("👁️👄👁️ 𝓊𝓃𝒿𝓊𝓇.");
}
connect(){
@ -91,6 +97,52 @@ class channel{
//Store queue lock status
this.queueLock = data.queueLock;
}
setDefaults(force = false, processConfig = false){
//Iterate through default config
for(let [key, value] of channel.defaultConfig){
//If the setting is unset or function was called forcefully
if(force || localStorage.getItem(key) == null){
//Set item from default map
localStorage.setItem(key, value);
}
//If we're running process steps for the config
if(processConfig){
//Process the current config value
this.processConfig(key, localStorage.getItem(key));
}
}
}
processConfig(key, value){
//Switch/case by config key
switch(key){
case 'ytPlayerType':
console.log("FUCK");
//If the user is running the embedded player
if(value == 'embed'){
//Find our footer
const footer = document.querySelector('footer');
//Create new script tag
const ytEmbedAPI = document.createElement('script');
//Link the iframe api from youtube
ytEmbedAPI.src = "https://www.youtube.com/iframe_api";
//set the iframe api script id
ytEmbedAPI.classList.add('yt-embed-api');
//Append the script tag to the top of the footer to give everything else access
footer.prepend(ytEmbedAPI);
}
//Stop while we're ahead
return;
}
}
static defaultConfig = new Map([
["ytPlayerType","raw"]
]);
}
const client = new channel();