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

feat: schema changes and updated UI fixes #9 fixes #1

This commit is contained in:
Mitesh Shah
2020-08-05 11:53:21 +05:30
parent 2acef931eb
commit 46a5310aed
4 changed files with 90 additions and 35 deletions

View File

@@ -17,7 +17,10 @@ function onStartup(){
chrome.storage.sync.get(['betterSourceURL'], function(result) {
console.log('Value currently is ' + (result.betterSourceURL || DEFAULT_LIST_URL));
fetch((result.betterSourceURL || DEFAULT_LIST_URL))
var listUrl = result.betterSourceURL || DEFAULT_LIST_URL
// Uncomment this when testing list changes locally
// listUrl = "/defaultlist.json"
fetch(listUrl)
.then(response => response.json())
.then(data => {
console.log("Got data: ", data);
@@ -30,9 +33,9 @@ function onStartup(){
}
function getMatch(url){
var match = BETTER_ALTERNATIVES.find(pattern => url.match(new RegExp(pattern[0])));
if(match)
return match[1];
var match = BETTER_ALTERNATIVES.find(pattern => url.match(new RegExp(pattern.urlPattern)));
if(match && match.alternatives)
return match.alternatives;
else return null;
}