commit ee74087c34b380e39d314248c174079cdf278977 Author: OverPoweredDev Date: Fri Jun 18 14:39:23 2021 +0530 added features to websiteList diff --git a/src/background/storage.js b/src/background/storage.js index aa48ce0..f1c1a46 100644 --- a/src/background/storage.js +++ b/src/background/storage.js @@ -5,6 +5,7 @@ function getGlobalSettings() { settings = { apertiumSource: "https://apertium.org/apy/", defaultLanguage: "eng", + enabledWebsites: ["en.wikipedia.org", "stackoverflow.com"], lastUpdated: "on Installation", inputSizeLimit: 1000 }; @@ -228,11 +229,18 @@ function getTranslationEndpoint() { //TODO: Enabled Website List function getEnabledWebsiteList(){ - return ["https://wikipedia.com", "https://www.youtube.com", "https://stackoverflow.com"]; + let settings = getGlobalSettings(); + return settings.enabledWebsites; } -function saveEnabledWebsiteList() { +function saveEnabledWebsiteList(newList) { + if(newList === null) { + return; + } + let settings = getGlobalSettings(); + settings.enabledWebsites = newList; + saveGlobalSettings(); } function removeFromEnabledWebsiteList(url){ diff --git a/src/content/content.js b/src/content/content.js index bf79c56..6486c14 100644 --- a/src/content/content.js +++ b/src/content/content.js @@ -1,3 +1,6 @@ -console.log(document); +enabledList = getEnabledWebsiteList(); + +if(enabledList.includes(window.location.hostname)) { + addHoverTag(); +} -addHoverTag(); \ No newline at end of file diff --git a/src/manifest.json b/src/manifest.json index 288c030..2cf7222 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -25,6 +25,7 @@ "background": { "scripts": [ "background/jquery.min.js", + "background/storage.js", "background/background.js" ], "persistent": false @@ -38,6 +39,7 @@ "js": [ "background/jquery.min.js", "content/hover.js", + "background/storage.js", "content/content.js" ] }