A
A
Acidburn82019-05-09 22:46:12
JavaScript
Acidburn8, 2019-05-09 22:46:12

How to close desired tab(url) in chrome extension?

How to make it so that when installing the extension, a certain open tab (yurl) closes?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rogiivs, 2019-05-10
@Acidburn8

chrome.runtime.onInstalled.addListener(() => {
    chrome.tabs.query({
        url: '' //тут нужный URL
    }, Tabs => {
        Tabs.forEach(Tab => {
            chrome.tabs.remove(Tab.id);
        });
    });
});

M
MamaLuyba, 2019-05-09
@MamaLuyba

on the onInstalled event you hang a handler that will find the desired tab and close it via window.close()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question