Answer the question
In order to leave comments, you need to log in
Is it possible to prevent a minimized tab, or a closed Google Chrome browser, from falling asleep?
Is it possible to make it so that after some time, let's say an hour or two, the tabs in the minimized browser do not fall asleep and are not updated when the cursor accesses these tabs? Required for the extension to run in the background
Answer the question
In order to leave comments, you need to log in
Yes, in theory, you can disable the unloading of tabs by applying 2 tricks.
Add to background.js :
chrome.tabs.onCreated.addListener(function(tab) {
chrome.tabs.update(tab.id, {
autoDiscardable: false
});
});
chrome.tabs.onReplaced.addListener(function(tabId) {
chrome.tabs.update(tabId, {
autoDiscardable: false
});
});
chrome.runtime.onInstalled.addListener(function(details) {
chrome.tabs.query({}, function(tabs) {
tabs.forEach(function(tab) {
chrome.tabs.update(tab.id, {
autoDiscardable: false
});
});
});
});
...
"permissions" : [ "tabs" ],
"background" : { "persistent": true, "scripts": [ "background.js" ] },
...
<video id="antifreeze" style="position: fixed; right: 30px; bottom: 30px; z-index: 99999; height: 55px; width: 300px;" controls loop name="media">
<source src="https://qna.habr.com/silence.mp3" type="audio/mpeg">
</video>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question