From ba12ee4dce5cda80a8ecb43760555f10bce6ccb6 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 6 Oct 2018 17:16:28 +0200 Subject: Fix CSS getting applied to incorrect sites from 4792514bbcf4aa0c1b102a3a 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. --- background.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'background.js') 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' } + ); + } }); }); -- cgit v1.2.3