Mudanças entre as edições de "Widget:Twitch"

De Wiki Gla
Ir para navegação Ir para pesquisar
 
(Uma revisão intermediária pelo mesmo usuário não está sendo mostrada)
Linha 1: Linha 1:
<includeonly>
<includeonly>
<div id="streamers-ativos">
<div id="streamers-ativos">
   <p>Carregando streamers ativos...</p>
   <!-- Streamers aparecerão aqui -->
</div>
</div>


Linha 7: Linha 7:
   const clientId = '3cqgn6bg1ts9bm3pahx51aiivs2u3d'; // Seu Client ID
   const clientId = '3cqgn6bg1ts9bm3pahx51aiivs2u3d'; // Seu Client ID
   const accessToken = 'v86kvw6tyfvrzv8hkti27ddt21ydjf'; // Seu Access Token
   const accessToken = 'v86kvw6tyfvrzv8hkti27ddt21ydjf'; // Seu Access Token
   const streamers = ['sayurimei', 'apolotfg', 'Yoshimitsuccs', 'pelotalul']; // Lista dos streamers
   const streamers = ['sayurimei', 'apolotfg', 'Yoshimitsuccs']; // Lista dos streamers


   async function fetchActiveStreamers() {
   async function fetchActiveStreamers() {
Linha 28: Linha 28:
         .filter((stream) => stream !== null) // Filtra apenas os streamers ativos
         .filter((stream) => stream !== null) // Filtra apenas os streamers ativos
         .filter((stream) => /GLA/i.test(stream.title)); // Verifica se o título contém "GLA" (case insensitive)
         .filter((stream) => /GLA/i.test(stream.title)); // Verifica se o título contém "GLA" (case insensitive)
        .filter((stream) => /curse/i.test(stream.title)); // Verifica se o título contém "GLA" (case insensitive)


       // Atualiza o HTML com os streamers ativos que têm "GLA" no título
       // Atualiza o HTML com os streamers ativos que têm "GLA" no título
Linha 34: Linha 33:
       if (activeStreamers.length > 0) {
       if (activeStreamers.length > 0) {
         container.innerHTML = activeStreamers.map((stream) => `
         container.innerHTML = activeStreamers.map((stream) => `
           <div class="streamer">
           <div class="streamer" id="streamer-${stream.user_name}">
             <h3>${stream.user_name}</h3>
             <h3>${stream.user_name}</h3>
             <p>${stream.title}</p>
             <p>${stream.title}</p>
Linha 48: Linha 47:
         `).join('');
         `).join('');
       } else {
       } else {
         container.innerHTML = '<p>Nenhum streamer ativo com "GLA" no título no momento.</p>';
         container.innerHTML = ''; // Deixa vazio se nenhum streamer ativo for encontrado
       }
       }
     } catch (error) {
     } catch (error) {
       console.error('Erro ao buscar streamers:', error);
       console.error('Erro ao buscar streamers:', error);
       document.getElementById('streamers-ativos').innerHTML = '<p>Erro ao carregar streamers. Tente novamente mais tarde.</p>';
       document.getElementById('streamers-ativos').innerHTML = ''; // Deixa vazio em caso de erro
     }
     }
   }
   }


   fetchActiveStreamers();
  // Atualiza os streamers ativos periodicamente (a cada 1 minuto)
   fetchActiveStreamers(); // Chamada inicial
  setInterval(fetchActiveStreamers, 60000); // Atualiza a cada 60 segundos
</script>
</script>



Edição atual tal como às 14h36min de 28 de dezembro de 2024