Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!