1
0
mirror of https://github.com/nileshtrivedi/better synced 2025-06-27 09:03:11 +02:00

Fix remote list loading

This commit is contained in:
Nilesh
2020-08-02 23:30:38 +05:30
parent e284d5c6ad
commit 2d5d6a2f4d
5 changed files with 23 additions and 8 deletions

View File

@@ -3,9 +3,10 @@ var BETTER_ALTERNATIVES = [];
chrome.runtime.onInstalled.addListener(function() {
console.log('onInstalled....');
onStartup();
});
// fetch and save data when chrome restarted, alarm will continue running when chrome is restarted
// fetch and save data when chrome restarted
chrome.runtime.onStartup.addListener(() => {
console.log('onStartup....');
onStartup();
@@ -29,7 +30,7 @@ function onStartup(){
}
function getMatch(url){
var match = BETTER_ALTERNATIVES.find(pattern => url.match(new Regexp(pattern[0])));
var match = BETTER_ALTERNATIVES.find(pattern => url.match(new RegExp(pattern[0])));
if(match)
return match[1];
else return null;
@@ -40,6 +41,9 @@ chrome.runtime.onMessage.addListener((msg, sender, response) => {
case 'getMatch':
response(getMatch(msg.url));
break;
case 'reloadList':
onStartup();
break;
default:
response('unknown request');
break;