script.jp
1 2 3 4 5 6 7 |
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { if (changeInfo.status === 'complete') { if (tab.title.includes("アラート!")) { chrome.tabs.remove(tabId); } } }); |
manifest.json
1 2 3 4 5 6 7 8 9 |
{ "manifest_version": 3, "name": "AutoCloseTab", "version": "1.0", "permissions": ["tabs"], "background": { "service_worker": "script.js" } } |