Skip to content

Commit

Permalink
obs...
Browse files Browse the repository at this point in the history
  • Loading branch information
Miala-python committed Mar 15, 2024
1 parent 8f72578 commit 576afff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
23 changes: 13 additions & 10 deletions lib/pl_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,26 @@ function plv_load() {
}

if ('PerformanceObserver' in window) {
// ... le reste du code ...

// Créer un observateur de performance
const observer = new PerformanceObserver((entries) => {
// Vérifier si le navigateur est stable
const isStable = entries.some((entry) => entry.name === 'longtask' && entry.duration <= 100);
// Vérifier si le type d'entrées est 'longtask' et s'il s'agit d'un tableau
if (entries instanceof Array && entries.every((entry) => 'longtask' in entry)) {
// Utiliser 'some' pour la recherche
// Si aucune tâche longue ne prend plus de 100ms, le navigateur est stable
const isStable = entries.some((entry) => entry.duration <= 100);

if (isStable) {
// Déconnecter l'observateur
observer.disconnect();

// Exécuter la fonction
plv_load();
if (isStable) {
observer.disconnect();
plv_load();
}
}
});

// Observer les entrées de performance de type "longtask"
// Observer les entrées de performance de type 'longtask'
observer.observe({ type: 'longtask' });


}else{
setTimeout(plv_load, 1000);
}
Expand Down
3 changes: 1 addition & 2 deletions loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,7 @@ function onYouTubeIframeAPIReady() {
'onStateChange': onPlayerStateChange,
'onError': onERR
},
controlslist: ["previous", "playpause", "next", "mute", "volume", "fullscreen", "pip"],
origin: 'https://yt.mi.42web.io'
controlslist: ["previous", "playpause", "next", "mute", "volume", "fullscreen", "pip"]
});


Expand Down

0 comments on commit 576afff

Please # to comment.