Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update icon colors #33

Merged
merged 11 commits into from
Mar 27, 2020
40 changes: 32 additions & 8 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,35 @@ versionIconMap.set('TLSv1.3', 'icons/tlsv13.png');
versionIconMap.set('TLSv1.2', 'icons/tlsv12.png');
versionIconMap.set('TLSv1.1', 'icons/tlsv11.png');
versionIconMap.set('TLSv1', 'icons/tlsv10.png');
versionIconMap.set('SSLv3', 'icons/sslv3.png'); /* no longer supported */
versionIconMap.set('unknown', 'icons/tlsunknown.png');

var versionIconWarningMap = new Map();
versionIconWarningMap.set('TLSv1.3', 'icons/tlsv13_warning.png');
versionIconWarningMap.set('TLSv1.2', 'icons/tlsv12_warning.png');
versionIconWarningMap.set('TLSv1.1', 'icons/tlsv11_warning.png');
versionIconWarningMap.set('TLSv1', 'icons/tlsv10_warning.png');
versionIconWarningMap.set('unknown', 'icons/tlsunknown.png');
Madis0 marked this conversation as resolved.
Show resolved Hide resolved

var versionComparisonMap = new Map();
versionComparisonMap.set('TLSv1.3', 13);
versionComparisonMap.set('TLSv1.2', 12);
versionComparisonMap.set('TLSv1.1', 11);
versionComparisonMap.set('TLSv1', 10);
versionComparisonMap.set('SSLv3', 3);
versionComparisonMap.set('unknown', 0);

var tabMainProtocolMap = new Map();
var tabSubresourceProtocolMap = new Map();

async function updateIcon(tabId, protocolVersion) {
browser.pageAction.setIcon({
tabId: tabId, path: versionIconMap.get(protocolVersion)
});
async function updateIcon(tabId, protocolVersion, warning) {
if (warning) {
browser.pageAction.setIcon({
tabId: tabId, path: versionIconWarningMap.get(protocolVersion)
});
} else {
browser.pageAction.setIcon({
tabId: tabId, path: versionIconMap.get(protocolVersion)
});
}
browser.pageAction.setTitle({tabId: tabId, title: protocolVersion});
browser.pageAction.setPopup({tabId: tabId, popup: "/popup/popup.html"});
}
Expand Down Expand Up @@ -49,8 +60,13 @@ async function processSecurityInfo(details) {

// save the security info for the current tab and update the page action icon
if (details.type === 'main_frame') {
tabMainProtocolMap.set(details.tabId, securityInfo);
await updateIcon(details.tabId, securityInfo.protocolVersion);
tabMainProtocolMap.set(details.tabId, securityInfo.protocolVersion);
await updateIcon(details.tabId, securityInfo.protocolVersion, false);
} else {
cached_version = tabMainProtocolMap.get(details.tabId);
if (typeof cached_version !== "undefined") {
await updateIcon(details.tabId, cached_version, false);
}
}

// save the security info for third party hosts that were loaded within
Expand All @@ -60,6 +76,14 @@ async function processSecurityInfo(details) {
subresourceMap.set(host, securityInfo);
tabSubresourceProtocolMap.set(details.tabId, subresourceMap);

var mainProtocolVersion = versionComparisonMap.get(tabMainProtocolMap.get(details.tabId));
for (const securityInfo of subresourceMap.values()) {
if (versionComparisonMap.get(securityInfo.protocolVersion) < mainProtocolVersion) {
await updateIcon(details.tabId, tabMainProtocolMap.get(details.tabId), true);
break;
}
}

} catch(error) {
console.error(error);
}
Expand Down
Binary file removed icons/src/sslv3.png
Binary file not shown.
Binary file removed icons/src/sslv3.xcf
Binary file not shown.
Binary file removed icons/src/sslv3_warning.png
Binary file not shown.
Binary file modified icons/src/tlsunknown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/src/tlsv10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/src/tlsv10.xcf
Binary file not shown.
Binary file modified icons/src/tlsv10_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/src/tlsv11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/src/tlsv11.xcf
Binary file not shown.
Binary file modified icons/src/tlsv11_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/src/tlsv12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/src/tlsv12.xcf
Binary file not shown.
Binary file modified icons/src/tlsv12_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/src/tlsv13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/src/tlsv13.xcf
Binary file not shown.
Binary file modified icons/src/tlsv13_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/src/tlsvunknown.xcf
Binary file not shown.
Binary file removed icons/sslv3.png
Binary file not shown.
Binary file removed icons/sslv3_warning.png
Binary file not shown.
Binary file modified icons/tlsunknown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/tlsv10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/tlsv10_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/tlsv11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/tlsv11_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/tlsv12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/tlsv12_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/tlsv13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/tlsv13_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions popup/popup.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
var protocolColorMap = new Map();
protocolColorMap.set('TLSv1.3', '#26de81');
protocolColorMap.set('TLSv1.2', '#20bf6b');
protocolColorMap.set('TLSv1.1', '#fed330');
protocolColorMap.set('TLSv1', '#eb3b5a');
protocolColorMap.set('SSLv3', '#eb3b5a');
protocolColorMap.set('TLSv1.2', '#fbc02d');
protocolColorMap.set('TLSv1.1', '#ff0000');
protocolColorMap.set('TLSv1', '#ff0000');

function request(resource, key) {
const request = browser.runtime.sendMessage({
Expand Down