From 270b0bf0cd9b464b1fa3929915dbd268f4307c85 Mon Sep 17 00:00:00 2001 From: izidorio Date: Tue, 21 Dec 2021 17:19:08 -0300 Subject: [PATCH] fix --- src/js/models/handle.js | 5 +++-- src/js/models/scraping.js | 9 ++++++--- src/js/models/setButtons.js | 12 +++++++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/js/models/handle.js b/src/js/models/handle.js index 59a7ff9..af7945d 100644 --- a/src/js/models/handle.js +++ b/src/js/models/handle.js @@ -28,14 +28,15 @@ export async function preview(){ const name = nameGroup(); const created = dateCreatedGroup(); + readGroup().then( ( contacts ) => { contacts.sort( (a, b) => { return b.admin - a.admin; }) - - let html = `${name}${style}

${name} (${contacts.length} participantes, ${created})

`; + const meta = ''; + let html = `${meta}${name}${style}

${name} (${contacts.length} participantes, ${created})

`; let cards = ''; let i = 1; diff --git a/src/js/models/scraping.js b/src/js/models/scraping.js index ac3d9be..209f70c 100644 --- a/src/js/models/scraping.js +++ b/src/js/models/scraping.js @@ -28,12 +28,15 @@ export function dateCreatedGroup() { export async function readGroup() { - await setHeight('9999999999px'); + // await setHeight('9999999999px'); + return new Promise( async ( resolve ) => { setTimeout( () => { // div que envolve o avatar e os dados dos participantes do grupo - const elements = document.querySelectorAll('._2nY6U._3A-iD'); + let elements = document.querySelectorAll('._2nY6U._3A-iD'); + + let contacts = []; for (let item of elements){ @@ -83,7 +86,7 @@ export async function readGroup() { } resolve(contacts); - setHeight('100%'); + //setHeight('100%'); }, 1500); diff --git a/src/js/models/setButtons.js b/src/js/models/setButtons.js index 8f80654..7ef07d4 100644 --- a/src/js/models/setButtons.js +++ b/src/js/models/setButtons.js @@ -1,6 +1,7 @@ const btnCopy = ``; const btnDown = ``; const btnPrt = ``; +const btnPrtModal = ``; import { saveCsv, preview, contactsToClipboard } from './handle.js'; @@ -84,7 +85,6 @@ const setButtons = setInterval( () => { const wrapper_participantes = document.querySelector('._3e6xi'); - console.log(); if( wrapper_participantes && !document.getElementById('btnCopy')){ const text = wrapper_participantes.innerHTML; @@ -103,6 +103,16 @@ const setButtons = setInterval( () => { } } + + const header = document.querySelector('header.-bGGW'); + if(header && !document.getElementById('btnPrtModal')){ + const button = document.createElement("div") + button.addEventListener("click", preview); + button.setAttribute('style',"margin-left: -25px; cursor: pointer") + button.innerHTML = `${btnPrtModal}`; + header.appendChild(button); + } + }, 2000);