Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
Get number of tabs opened with Bulk URL Opener using AutoHotkey

I use an extension in Chrome (Bulk URL Opener). This extension opens multiple links at an interval of seconds. It also opens a new tab (x1) that has play and pause buttons. When pressing the play button, the extension starts opening new tabs to the right and keeps opening. When pressing the pause button, it stops the opening of a new tab.

What I want AutoHotkey to do here is to read the number of tabs opened in Chrome. If there are less than 10 tabs, then I want AutoHotkey to give input to the x1 tab and start the opening of the new tab. Also, if the number of opened tabs is more than 12, then I want AutoHotkey to give input again to the x1 tab and stop the opening of a new tab.

Basically, I want only 10 or 12 tabs to be opened in Chrome at once and if I close a tab or two I want a new tab to be automatically opened. Is there a way that I can achieve this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Read this source: https://dev.to/dcodeyt/send-data-between-tabs-with-javascript-2oa

Initializing a channel happens like this:

const channel = new BroadcastChannel("my-channel");

This is how you can receive a message:

channel.addEventListener("message", e => {
    console.log(e.data);
});

This is how you can post a message

channel.postMessage("Hello world");

Now, knowing all these, let's see the

Solution

If you open tabs, you will open some URL for each of them. Assuming that you are in control of the source-code of the pages you open, you can do the following:

  • Initialize a channel both on your main tab and the open tabs
  • Create a message event listener both on your main tab and the open tabs
  • Whenever you might want to open tabs, post messages to the sub-tabs and see how many responses you get

Example

Child event listener

const channel = new BroadcastChannel("my-channel");
channel.addEventListener("message", e => {
    if (e.data === "ping") channel.postMessage("pong");
});

Main event listener

var pongCount = 0;
var pongLimit = 12;
const channel = new BroadcastChannel("my-channel");
channel.addEventListener("message", e => {
    if (e.data === "pong") pongCount++;
});

Tick

setInterval(function() {
    pongCount = 0;
    channel.postMessage("ping");
    setTimeout(function() {
        for (let pongIndex = pongCount + 1; pongIndex < pongLimit; pongIndex++) {
            //open a tab
        }
    }, 100);
}, 1000);

Note that the tick code needs to be in the main tab

EDIT

It seems that there is no access to the pages that are being loaded. If that's the case, one can implement a proxy app that will transmit the request to the target pages to bypass Chrome's restrictions and have wrapper pages where you have full access in terms of source-code and therefore that would be able to send and receive messages.

Alternatively one can use the chrome.tabs extension, like

chrome.tabs.query({windowType:'normal'}, function(tabs) {
    console.log('Number of open tabs in all normal browser windows:',tabs.length);
}); 

But for that purpose, the given extension will be needed to be installed: https://developer.chrome.com/docs/extensions/reference/tabs/

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda