diff options
author | Teddy Wing | 2018-10-06 17:16:28 +0200 |
---|---|---|
committer | Teddy Wing | 2018-10-06 17:16:28 +0200 |
commit | ba12ee4dce5cda80a8ecb43760555f10bce6ccb6 (patch) | |
tree | 2604044bc0dbf07a4be20be4dac97cc7c5643546 /background.js | |
parent | 4792514bbcf4aa0c1b102a3afc25c8c0ae4636b5 (diff) | |
download | Legibility-ba12ee4dce5cda80a8ecb43760555f10bce6ccb6.tar.bz2 |
Fix CSS getting applied to incorrect sites from 4792514bbcf4aa0c1b102a3av0.0.1
That commit incorrectly caused a bunch (if not all) custom stylesheets
to be inserted for the wrong domains.
Add a condition to ensure that the domain of the `tabId` used matches
that of the stylesheet.
Diffstat (limited to 'background.js')
-rw-r--r-- | background.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/background.js b/background.js index 7510556..c898d8c 100644 --- a/background.js +++ b/background.js @@ -23,9 +23,13 @@ if (chrome) { browser.runtime.onMessage.addListener(function(message) { browser.webNavigation.onCompleted.addListener(function(details) { - browser.tabs.insertCSS( - details.tabId, - { file: '/css/' + message.domain + '.css' } - ); + var url = new URL(details.url); + + if (url.hostname === message.domain) { + browser.tabs.insertCSS( + details.tabId, + { file: '/css/' + message.domain + '.css' } + ); + } }); }); |