@LonM Ayyy, thank you very much! Works as I envisioned! β€
I doubt it's the very best way to do it, but if anyone is interested in a simple auto-hibernation for new background tabs, here's what I got in background.js:
chrome.tabs.onUpdated.addListener(function (tabId,info,tab) {
if (!(/"read":true/.test(tab.extData))&&tab.title!=""&&!(/^http/.test(tab.title)))
chrome.tabs.query({active: true, currentWindow: true},function(tabs) {
if(tabs[0].id!=tabId) chrome.tabs.discard(tabId);
});
});
Interestingly, tab.url is always present, but if you hibernate the tab right away, it will stay empty on wakeup, so I check the title instead, and to make it more user-friendly, wait for it to display the actual title of the page, not just url, as it does at first. :3 Thanks again!
Edit, right away: There still seems to be a window of time when the page becomes unresponsive, so it will need more work. If you can read this, I still wasn't motivated enough to fix it π