|
1 | | -updateurls(); setInterval(updateurls, 10000); |
| 1 | +chrome.tabs.onCreated.addListener(function(tab) { |
| 2 | + if(tab.status === "complete") chrome.tabs.reload(tab.id); |
| 3 | + chrome.tabs.update(tab.id, {autoDiscardable: false}); |
| 4 | +}); |
2 | 5 |
|
3 | | -chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){ |
4 | | - if(urls.length === 0) return; |
5 | | - if(changeInfo.url) { |
6 | | - chrome.tabs.query({url: urls}, function(tabs) { |
7 | | - if(tabs === undefined) { |
8 | | - updateurls(); |
9 | | - chrome.browserAction.setBadgeText({text: "error"}); |
10 | | - return; |
11 | | - } |
12 | | - chrome.browserAction.setBadgeText({text: ""}); |
13 | | - if(tabs.length === 0 && !(tab.autoDiscardable)) { |
14 | | - chrome.tabs.update(tabId, {autoDiscardable: true}); |
15 | | - } |
16 | | - if(tabs.length !== 0) { |
17 | | - for (i = 0; i < tabs.length; i++) { |
18 | | - if(tabs[i].id === tabId) { |
19 | | - if(tab.autoDiscardable) // If tab matches URL pattern and it should be marked as non discardable |
20 | | - chrome.tabs.update(tabId, {autoDiscardable: false}); |
21 | | - break; |
22 | | - } |
23 | | - if(i === tabs.length-1 && !(tab.autoDiscardable)) // If tab does not match URL pattern and should be marked as discardable |
24 | | - chrome.tabs.update(tabId, {autoDiscardable: true}); |
25 | | - } // Loop |
26 | | - } // If tabs found |
| 6 | +chrome.runtime.onInstalled.addListener(function(details) { |
| 7 | + chrome.tabs.query({}, function(tabs) { |
| 8 | + tabs.forEach(function(tab) { |
| 9 | + chrome.tabs.update(tab.id, {autoDiscardable: false}); |
27 | 10 | }); |
28 | | - } |
| 11 | + }); |
29 | 12 | }); |
30 | 13 |
|
31 | | -function updateurls() { |
32 | | - if(localStorage.getItem("urls")) urls = localStorage.getItem("urls").split(','); |
33 | | - else urls = []; |
34 | | -} |
| 14 | +chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { |
| 15 | + if(changeInfo.discarded) chrome.tabs.reload(tabId); |
| 16 | +}); |
0 commit comments