Skip to content

Instantly share code, notes, and snippets.

@greatghoul
Last active March 22, 2016 06:27
Show Gist options
  • Save greatghoul/be64f7464ae2b0869f25 to your computer and use it in GitHub Desktop.
Save greatghoul/be64f7464ae2b0869f25 to your computer and use it in GitHub Desktop.
an extension tha each time I close a tab a new one open - https://redd.it/49j7h5
const mappings = {};
chrome.tabs.onCreated.addListener((tab) => {
mappings[tab.id] = tab.url;
});
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
mappings[tabId] = tab.url;
});
chrome.tabs.onRemoved.addListener((tabId, removeInfo) => {
const url = mappings[tabId]
console.log(`Closing ${url}`);
if (url != 'chrome://newtab/') {
chrome.tabs.create({});
}
});
{
"manifest_version": 2,
"name": "Keep Tab",
"version": "0.1",
"description": "an extension tha each time I close a tab a new one open - https://redd.it/49j7h5",
"background": {
"scripts": ["event.js"],
"persistent": true
},
"permissions": ["tabs"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment