fix typo,delete unnecessary type check

This commit is contained in:
bonjinnorenka 2023-09-03 09:04:04 +09:00
parent cb27c6a33a
commit bd35a5a149

View File

@ -33,8 +33,8 @@ class invidious_embed {
return; return;
} }
this.eventobject[internal_eventname] = this.eventobject[internal_eventname].filter(x => { this.eventobject[internal_eventname] = this.eventobject[internal_eventname].filter(x => {
const arrowFunctionDetected = x.toString()[0] === '('; const allowFunctionDetected = x.toString()[0] === '(';
if (arrowFunctionDetected) { if (allowFunctionDetected) {
x.toString() !== func.toString(); x.toString() !== func.toString();
} else { } else {
x !== func; x !== func;
@ -305,7 +305,7 @@ class invidious_embed {
setVolume(volume) { setVolume(volume) {
if (typeof volume === 'number') { if (typeof volume === 'number') {
this.volume = volume; this.volume = volume;
if (volume !== NaN && volume != undefined && volume >= 0 && volume <= 100) { if (volume !== NaN && volume >= 0 && volume <= 100) {
this.postMessage({ eventname: 'setvolume', value: volume / 100 }); this.postMessage({ eventname: 'setvolume', value: volume / 100 });
} }
} else { } else {
@ -521,5 +521,9 @@ function invidious_ready(func) {
invidious_embed.invidious_instance = new URL(document.currentScript.src).origin; invidious_embed.invidious_instance = new URL(document.currentScript.src).origin;
const invidious = { Player: invidious_embed, PlayerState: { ENDED: 0, PLAYING: 1, PAUSED: 2, BUFFERING: 3, CUED: 5 }, ready: invidious_ready }; const invidious = { Player: invidious_embed, PlayerState: { ENDED: 0, PLAYING: 1, PAUSED: 2, BUFFERING: 3, CUED: 5 }, ready: invidious_ready };
if (typeof onInvidiousIframeAPIReady === 'function') { if (typeof onInvidiousIframeAPIReady === 'function') {
try{
onInvidiousIframeAPIReady(); onInvidiousIframeAPIReady();
} catch(e) {
console.error(e);
}
} }