This repository was archived by the owner on Jun 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show browserAction as disabled when shield is off
fix #240
- Loading branch information
1 parent
38b2455
commit b1bbd81
Showing
4 changed files
with
44 additions
and
14 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
/** | ||
* Sets the badge text | ||
* @param {string} text - The text to put on the badge | ||
*/ | ||
export const setBadgeText = (text: string) => { | ||
if (chrome.browserAction) { | ||
chrome.browserAction.setBadgeText({ text: String(text) }) | ||
} | ||
} | ||
|
||
/** | ||
* Updates the shields icon based on shields state | ||
*/ | ||
export const setIcon = (url: string, tabId: number, shieldsOn: boolean) => { | ||
const shieldsEnabledIcon = '../../img/icon-16.png' | ||
const shieldsDisabledIcon = '../../img/icon-16-disabled.png' | ||
const isHttpOrHttps = url && /^http/.test(url) | ||
|
||
if (chrome.browserAction) { | ||
chrome.browserAction.setIcon({ | ||
path: shieldsOn && isHttpOrHttps ? shieldsEnabledIcon : shieldsDisabledIcon, | ||
tabId | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters