parent
cf0dcf2522
commit
efa1cb3967
11 changed files with 34 additions and 101 deletions
@ -1,15 +1,19 @@ |
|||||||
|
import messages from 'shared/messages'; |
||||||
import actions from 'content/actions'; |
import actions from 'content/actions'; |
||||||
|
|
||||||
const enable = () => { |
const enable = () => setEnabled(true); |
||||||
return { type: actions.ADDON_ENABLE }; |
|
||||||
}; |
|
||||||
|
|
||||||
const disable = () => { |
const disable = () => setEnabled(false); |
||||||
return { type: actions.ADDON_DISABLE }; |
|
||||||
}; |
|
||||||
|
|
||||||
const toggleEnabled = () => { |
const setEnabled = async(enabled) => { |
||||||
return { type: actions.ADDON_TOGGLE_ENABLED }; |
await browser.runtime.sendMessage({ |
||||||
|
type: messages.ADDON_ENABLED_RESPONSE, |
||||||
|
enabled, |
||||||
|
}); |
||||||
|
return { |
||||||
|
type: actions.ADDON_SET_ENABLED, |
||||||
|
enabled, |
||||||
|
}; |
||||||
}; |
}; |
||||||
|
|
||||||
export { enable, disable, toggleEnabled }; |
export { enable, disable, setEnabled }; |
||||||
|
@ -1,13 +1,13 @@ |
|||||||
import * as re from 'shared/utils/re'; |
import * as re from 'shared/utils/re'; |
||||||
|
|
||||||
const includes = (blacklist, url) => { |
const includes = (blacklist, url) => { |
||||||
let u = new URL(url) |
let u = new URL(url); |
||||||
return blacklist.some((item) => { |
return blacklist.some((item) => { |
||||||
if (!item.includes('/')) { |
if (!item.includes('/')) { |
||||||
return re.fromWildcard(item).test(u.hostname); |
return re.fromWildcard(item).test(u.hostname); |
||||||
} |
} |
||||||
return re.fromWildcard(item).test(u.hostname + u.pathname); |
return re.fromWildcard(item).test(u.hostname + u.pathname); |
||||||
}); |
}); |
||||||
} |
}; |
||||||
|
|
||||||
export { includes }; |
export { includes }; |
||||||
|
@ -1,25 +0,0 @@ |
|||||||
import actions from 'content/actions'; |
|
||||||
import * as addonActions from 'content/actions/addon'; |
|
||||||
|
|
||||||
describe("addon actions", () => { |
|
||||||
describe("enable", () => { |
|
||||||
it('create ADDON_ENABLE action', () => { |
|
||||||
let action = addonActions.enable(); |
|
||||||
expect(action.type).to.equal(actions.ADDON_ENABLE); |
|
||||||
}); |
|
||||||
}); |
|
||||||
|
|
||||||
describe("disable", () => { |
|
||||||
it('create ADDON_DISABLE action', () => { |
|
||||||
let action = addonActions.disable(); |
|
||||||
expect(action.type).to.equal(actions.ADDON_DISABLE); |
|
||||||
}); |
|
||||||
}); |
|
||||||
|
|
||||||
describe("toggle", () => { |
|
||||||
it('create ADDON_TOGGLE_ENABLED action', () => { |
|
||||||
let action = addonActions.toggleEnabled(); |
|
||||||
expect(action.type).to.equal(actions.ADDON_TOGGLE_ENABLED); |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
Reference in new issue