aboutsummaryrefslogtreecommitdiffstats
path: root/background.js
diff options
context:
space:
mode:
authorTeddy Wing2018-08-04 03:35:30 +0200
committerTeddy Wing2018-08-04 03:35:30 +0200
commit0db68f29c4631338e8fee87c9d819f2ea21ba032 (patch)
tree55575f12d9ddca41f4303cfc2f585dc6c31aa091 /background.js
parent76f1058d353100c0e73720349da1c79f0aa2c193 (diff)
downloadLegibility-0db68f29c4631338e8fee87c9d819f2ea21ba032.tar.bz2
Match CSS files with the domain hostname
Load a CSS file based on the current page's domain (e.g. "example.com"). Use: https://stackoverflow.com/questions/13367376/get-the-domain-name-of-the-subdomain-javascript/13367604#13367604 to give us the hostname without any subdomains. This will apply the CSS to all subdomains on the site. Not sure if this what we want yet, but it seemed simpler to consolidate like this now rather than splitting CSS by each subdomain or adding some kind of complicated matching/wildcard logic. Errors are ignored and just happen if the file for the current domain doesn't exist. This seems okay to me to leave errors unhandled, as there doesn't appear to be a clean way to handle them, and even if there was, we'd just be either ignoring them anyway or conditionally executing `insertCSS()`, which seems unnecessary.
Diffstat (limited to 'background.js')
-rw-r--r--background.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/background.js b/background.js
index 44a5c2a..f8b3a71 100644
--- a/background.js
+++ b/background.js
@@ -4,6 +4,6 @@ if (chrome) {
browser = chrome;
}
-browser.runtime.onMessage.addListener(function() {
- browser.tabs.insertCSS({ file: '/css/example.com.css' });
+browser.runtime.onMessage.addListener(function(message) {
+ browser.tabs.insertCSS({ file: '/css/' + message.domain + '.css' });
});