diff --git a/src/js/background.ts b/src/js/background.ts index 6ca07b6b..832af90a 100644 --- a/src/js/background.ts +++ b/src/js/background.ts @@ -1,7 +1,7 @@ // tslint:disable-next-line:variable-name const _browser = chrome || browser; let tags: string[] = []; -let amazonTagRemoverNotification: string = 'amazon-tag-remover-notification'; +const amazonTagRemoverNotification = 'amazon-tag-remover-notification'; const amazonURLs = [ '*://*.amazon.at/*', '*://*.amazon.ca/*', @@ -11,6 +11,7 @@ const amazonURLs = [ '*://*.amazon.com.au/*', '*://*.amazon.com.br/*', '*://*.amazon.com.mx/*', + '*://*.amazon.com.tr/*', '*://*.amazon.com/*', '*://*.amazon.de/*', '*://*.amazon.es/*', @@ -20,6 +21,7 @@ const amazonURLs = [ '*://*.amazon.it/*', '*://*.amazon.nl/*' ]; +const storage = _browser.storage.sync || _browser.storage.local; _browser.webRequest.onBeforeRequest.addListener( interceptRequest, @@ -31,8 +33,8 @@ _browser.webRequest.onBeforeRequest.addListener( _browser.webNavigation.onCompleted.addListener( () => { if (tags && tags.length) { - const enableNotifications = _browser.storage.local.get('enableNotifications', (item: any) => { - if (item.enableNotifications) { + storage.get('disableNotifications', (item: any) => { + if (!item.disableNotifications) { _browser.notifications.create(amazonTagRemoverNotification, { iconUrl: _browser.extension.getURL('images/icon64.png'), message: `The following tags were found and have been removed: ${tags}`, @@ -41,12 +43,13 @@ _browser.webNavigation.onCompleted.addListener( }); } }); + tags = []; } }, { url: [ { - urlMatches: 'https?://w*.?amazon.(at|ca|cn|co.jp|co.uk|com.au|com.br|com.mx|com|de|es|fr|ie|in|it|nl)/w*' + urlMatches: 'https?://w*.?amazon.(at|ca|cn|co.jp|co.uk|com.au|com.br|com.mx|com.tr|com|de|es|fr|ie|in|it|nl)/w*' } ] } diff --git a/src/js/options.ts b/src/js/options.ts index a7671a75..f3e5fcd0 100644 --- a/src/js/options.ts +++ b/src/js/options.ts @@ -1,19 +1,21 @@ // tslint:disable-next-line:variable-name const __browser = chrome || browser; +// tslint:disable-next-line:variable-name +const _storage = __browser.storage.sync || __browser.storage.local; function saveOptions(e: Event) { e.preventDefault(); - __browser.storage.local.set({ - enableNotifications: document.querySelector('#enable-notifications')!.checked + _storage.set({ + disableNotifications: document.querySelector('#disable-notifications')!.checked }); } function restoreOptions() { function setCurrentChoice(result: any) { - document.querySelector('#enable-notifications')!.checked = result.enableNotifications; + document.querySelector('#disable-notifications')!.checked = result.disableNotifications; } - __browser.storage.local.get('enableNotifications', setCurrentChoice); + _storage.get('disableNotifications', setCurrentChoice); } document.addEventListener('DOMContentLoaded', restoreOptions); diff --git a/src/manifest.json b/src/manifest.json index b6fb8ac6..a369cf2e 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,35 +1,13 @@ { "name": "Amazon Tag Remover", "version": "0.4.0", - "minimum_chrome_version": "62", + "minimum_chrome_version": "67", "manifest_version": 2, "author": "Tim 'timbru31' Brust", "description": "Remove the Amazon affiliate tracking ID (tag) from amazon links", "background": { "scripts": ["js/background.js"] }, - "content_scripts": [ - { - "matches": [ - "*://*.amazon.at/*", - "*://*.amazon.ca/*", - "*://*.amazon.cn/*", - "*://*.amazon.co.jp/*", - "*://*.amazon.co.uk/*", - "*://*.amazon.com.au/*", - "*://*.amazon.com.br/*", - "*://*.amazon.com.mx/*", - "*://*.amazon.com/*", - "*://*.amazon.de/*", - "*://*.amazon.es/*", - "*://*.amazon.fr/*", - "*://*.amazon.ie/*", - "*://*.amazon.in/*", - "*://*.amazon.it/*", - "*://*.amazon.nl/*" - ] - } - ], "options_ui": { "page": "options.html" }, @@ -49,6 +27,7 @@ "*://*.amazon.com.au/*", "*://*.amazon.com.br/*", "*://*.amazon.com.mx/*", + "*://*.amazon.com.tr/*", "*://*.amazon.com/*", "*://*.amazon.de/*", "*://*.amazon.es/*", diff --git a/src/options.html b/src/options.html index 6dfdea48..2c265909 100644 --- a/src/options.html +++ b/src/options.html @@ -1,18 +1,15 @@ + + + - - - - - -
- -
-
- -
- - - + +
+
+
+ +
+ +