stronger domain matching using sdk/url

Closes #79
This commit is contained in:
casebenton 2016-08-17 13:10:38 -07:00
Родитель 04b24aa843
Коммит ef90099bc3
2 изменённых файлов: 9 добавлений и 7 удалений

Просмотреть файл

@ -1,6 +1,6 @@
[
{
"domain": "wikipedia.org",
"domain": "www.wikipedia.org",
"data": [
{
"description": "See previews of linked articles.",
@ -13,7 +13,7 @@
]
},
{
"domain": "reddit.com",
"domain": "www.reddit.com",
"data": [
{
"description": "Must-have enhancements for Reddit.",
@ -39,7 +39,7 @@
]
},
{
"domain": "twitch.tv",
"domain": "www.twitch.tv",
"data": [
{
"description": "Get instant alerts and quickly browse Twitch streams.",
@ -60,7 +60,7 @@
]
},
{
"domain": "rt.com",
"domain": "www.rt.com",
"data": [
{
"description": "Get the latest RT News with a single click.",
@ -73,7 +73,7 @@
]
},
{
"domain": "facebook.com",
"domain": "www.facebook.com",
"data": [
{
"description": "Enjoy enhanced access to Facebook emoticons.",
@ -86,7 +86,7 @@
]
},
{
"domain": "amazon.com",
"domain": "www.amazon.com",
"data": [
{
"description": "See price comparisons and manage your Amazon activity right from the toolbar.",

Просмотреть файл

@ -1,6 +1,7 @@
const { AddonManager } = require('resource://gre/modules/AddonManager.jsm');
const { Panel: panel } = require('sdk/panel');
const self = require('sdk/self');
const sdkUrl = require('sdk/url');
const simplePrefs = require('sdk/simple-prefs');
const simpleStorage = require('sdk/simple-storage');
const tabs = require('sdk/tabs');
@ -152,8 +153,9 @@ class Recommender {
waitForWindow() {
const win = tabs.activeTab.window;
const button = this.getButton(win);
const tabHostname = sdkUrl.URL(tabs.activeTab.url).hostname; // eslint-disable-line new-cap
for (let rec of simpleStorage.storage.recData) { // eslint-disable-line prefer-const
if (tabs.activeTab.url.includes(rec.domain)) {
if (tabHostname === rec.domain) {
this.activeRecDomain = rec.domain;
this.prepPanel(rec.data);
this.telemetryLog.showButton(this.activeRecDomain);