I am currently developing a Chrome extension that is designed to automatically close tabs when specific URLs are visited, helping me stay focused and avoid distractions.
The list of sites that should trigger tab closures includes:
- YouTube
Interestingly, I have encountered a situation where some URLs that do not match the specified filters are still being closed. For example:
Could you offer some insight into this issue?
Below is a snippet of the code used in my extension:
chrome.webNavigation.onDOMContentLoaded.addListener(function(data) {
chrome.tabs.remove(data.tabId);
}, {url: [
{ hostContains: '.youtube' },
{ hostContains: '.twitter' },
{ hostContains: '.reddit' },
{ hostContains: '.facebook' }
]
});
Any help or suggestions would be greatly appreciated!