// Function to close tabs with about:blank URL or title or containing "unblocked games"
function closeTabs() {
chrome.tabs.query({}, function(tabs) {
// Loop through all tabs
tabs.forEach(function(tab) {
// Check if the tab's URL is "about:blank" or if its title is "about:blank" or contains "unblocked"
if (tab.url === "about:blank" || tab.title === "about:blank" || tab.title.toLowerCase().includes("unblocked")) {
// Close the tab
chrome.tabs.remove(tab.id);
}
});
});
}
// Function to reload the extension
function reloadExtension() {
chrome.runtime.reload();
}
// Event listener for when the extension is installed
chrome.runtime.onInstalled.addListener(function() {
// Close existing tabs on installation
closeTabs();
// Schedule closeTabs() to run every 30 Seconds (30000 milliseconds)
setInterval(closeTabs, 30000);
// Schedule reloadExtension() to run every 30 Seconds (30000 milliseconds)
setInterval(reloadExtension, 30000);
// Event listener for tab updates
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
// Check if the tab's URL is "about:blank" or if its title is "about:blank" or contains "unblocked games"
if (tab.url === "about:blank" || tab.title === "about:blank" || tab.title.toLowerCase().includes("unblocked games")) {
// Close the tab
chrome.tabs.remove(tabId);
}
});
});