Add HiDPI toolbar icon in Chrome (#471)

This commit is contained in:
Sami Vänttinen 2019-04-17 21:12:30 +03:00 committed by Janek Bevendorff
parent f493163212
commit e21c45b71d
34 changed files with 75 additions and 76 deletions

View file

@ -21,7 +21,7 @@ browserAction.show = function(callback, tab) {
browser.browserAction.setIcon({
tabId: tab.id,
path: '/icons/19x19/' + browserAction.generateIconName(data.iconType, data.icon)
path: '/icons/toolbar/' + browserAction.generateIconName(data.iconType, data.icon)
});
if (data.popup) {
@ -65,7 +65,7 @@ browserAction.update = function(interval) {
browser.browserAction.setIcon({
tabId: page.currentTabId,
path: '/icons/19x19/' + browserAction.generateIconName(null, data.intervalIcon.icons[data.intervalIcon.index])
path: '/icons/toolbar/' + browserAction.generateIconName(null, data.intervalIcon.icons[data.intervalIcon.index])
});
}
};
@ -193,7 +193,7 @@ browserAction.removeRememberPopup = function(callback, tab, removeImmediately) {
const currentMS = Date.now();
if (removeImmediately || (data.visibleForPageUpdates <= 0 && data.redirectOffset > 0)) {
browserAction.stackPop(tab.id);
browserAction.show(null, { 'id': tab.id } );
browserAction.show(null, { 'id': tab.id });
page.clearCredentials(tab.id);
} else if (!isNaN(data.visibleForPageUpdates) && data.redirectOffset > 0 && currentMS >= data.redirectOffset) {
data.visibleForPageUpdates -= 1;
@ -233,9 +233,9 @@ browserAction.setRememberPopup = function(tabId, username, password, url, userna
index: 0,
counter: 0,
max: 2,
icons: ['icon_remember_red_background_19x19.png', 'icon_remember_red_lock_19x19.png']
icons: [ 'icon_remember_red_background.png', 'icon_remember_red_lock.png' ]
},
icon: 'icon_remember_red_background_19x19.png',
icon: 'icon_remember_red_background.png',
popup: 'popup_remember.html'
};
@ -301,7 +301,7 @@ browserAction.generateIconName = function(iconType, icon) {
let name = 'icon_';
name += (keepass.keePassXCUpdateAvailable()) ? 'new_' : '';
name += (!iconType || iconType === 'normal') ? 'normal' : iconType;
name += '_19x19.png';
name += '.png';
return name;
};

View file

@ -241,7 +241,7 @@ kpxcEvent.onLoginPopup = function(callback, tab, logins) {
kpxcEvent.initHttpAuth = function(callback) {
httpAuth.init();
callback();
}
};
kpxcEvent.onHTTPAuthPopup = function(callback, tab, data) {
const stackData = {

View file

@ -57,7 +57,7 @@ const kpErrors = {
NO_URL_PROVIDED: 14,
NO_LOGINS_FOUND: 15,
errorMessages : {
errorMessages: {
0: { msg: tr('errorMessageUnknown') },
1: { msg: tr('errorMessageDatabaseNotOpened') },
2: { msg: tr('errorMessageDatabaseHash') },
@ -197,8 +197,8 @@ keepass.updateCredentials = function(callback, tab, entryId, username, password,
};
keepass.retrieveCredentials = function(callback, tab, url, submiturl, forceCallback, triggerUnlock = false, httpAuth = false) {
keepass.testAssociation((response) => {
if (!response) {
keepass.testAssociation((taResponse) => {
if (!taResponse) {
browserAction.showDefault(null, tab);
if (forceCallback) {
callback([]);
@ -569,7 +569,7 @@ keepass.getDatabaseHash = function(callback, tab, enableTimeout = false, trigger
keepass.setcurrentKeePassXCVersion(parsed.version);
keepass.databaseHash = parsed.hash || '';
if (oldDatabaseHash && oldDatabaseHash != keepass.databaseHash) {
if (oldDatabaseHash && oldDatabaseHash !== keepass.databaseHash) {
keepass.associated.value = false;
keepass.associated.hash = null;
}
@ -933,7 +933,7 @@ keepass.checkForNewKeePassXCVersion = function() {
}
if (version !== -1) {
browser.storage.local.set({'latestKeePassXC': keepass.latestKeePassXC});
browser.storage.local.set({ 'latestKeePassXC': keepass.latestKeePassXC });
}
};
@ -944,8 +944,7 @@ keepass.checkForNewKeePassXCVersion = function() {
try {
xhr.open('GET', keepass.latestVersionUrl, true);
xhr.send();
}
catch (ex) {
} catch (ex) {
console.log(ex);
}
keepass.latestKeePassXC.lastChecked = new Date().valueOf();

View file

@ -22,14 +22,14 @@ kpxcAutocomplete.create = function(input, showListInstantly = false) {
if (showListInstantly) {
showList(input);
}
}
function showList(input) {
function showList(inputField) {
closeList();
const div = kpxcUI.createElement('div', 'kpxcAutocomplete-items', { 'id': 'kpxcAutocomplete-list' });
// Element position
const rect = input.getBoundingClientRect();
const rect = inputField.getBoundingClientRect();
div.style.top = String((rect.top + document.body.scrollTop) + input.offsetHeight) + 'px';
div.style.left = String((rect.left + document.body.scrollLeft)) + 'px';
div.style.minWidth = String(input.offsetWidth) + 'px';
@ -48,10 +48,10 @@ kpxcAutocomplete.create = function(input, showListInstantly = false) {
// Save index for combination.loginId
const index = Array.prototype.indexOf.call(e.currentTarget.parentElement.childNodes, e.currentTarget);
input.value = this.getElementsByTagName('input')[0].value;
fillPassword(input.value, index);
inputField.value = this.getElementsByTagName('input')[0].value;
fillPassword(inputField.value, index);
closeList();
input.focus();
inputField.focus();
});
// These events prevent the double hover effect if both keyboard and mouse are used
@ -71,7 +71,7 @@ kpxcAutocomplete.create = function(input, showListInstantly = false) {
const items = getAllItems();
_index = 0;
activateItem(items);
};
}
function activateItem(item) {
if (!item || item.length === 0) {
@ -90,13 +90,13 @@ kpxcAutocomplete.create = function(input, showListInstantly = false) {
if (item[_index] !== undefined) {
item[_index].classList.add('kpxcAutocomplete-active');
}
};
}
function removeItem(items) {
for (const item of items) {
item.classList.remove('kpxcAutocomplete-active');
}
};
}
function closeList(elem) {
const items = document.getElementsByClassName('kpxcAutocomplete-items');
@ -105,7 +105,7 @@ kpxcAutocomplete.create = function(input, showListInstantly = false) {
item.parentNode.removeChild(item);
}
}
};
}
function getAllItems() {
const list = document.getElementById('kpxcAutocomplete-list');
@ -113,7 +113,7 @@ kpxcAutocomplete.create = function(input, showListInstantly = false) {
return [];
}
return list.getElementsByTagName('div');
};
}
/**
* Keyboard shortcuts for autocomplete menu:
@ -158,7 +158,7 @@ kpxcAutocomplete.create = function(input, showListInstantly = false) {
_index = -1;
showList(input);
}
};
}
function fillPassword(value, index) {
const fieldId = input.getAttribute('data-kpxc-id');
@ -168,7 +168,7 @@ kpxcAutocomplete.create = function(input, showListInstantly = false) {
kpxc.fillInCredentials(combination, false, false);
input.setAttribute('fetched', true);
};
}
// Detect click outside autocomplete
document.addEventListener('click', function(e) {

View file

@ -32,7 +32,7 @@ kpxcDefine.init = function() {
kpxcDefine.prepareStep1();
kpxcDefine.markAllUsernameFields('#kpxcDefine-fields');
kpxcDefine.dialog = $('#kpxcDefine-description');;
kpxcDefine.dialog = $('#kpxcDefine-description');
kpxcDefine.dialog.onmousedown = function(e) {
kpxcDefine.mouseDown(e);
};
@ -205,7 +205,7 @@ kpxcDefine.markFields = function(chooser, pattern) {
};
i.onfocus = function() {
field.classList.add('kpxcDefine-fixed-hover-field');
}
};
i.onblur = function() {
field.classList.remove('kpxcDefine-fixed-hover-field');
};

View file

@ -5,7 +5,6 @@ var _called = {};
_called.retrieveCredentials = false;
_called.clearLogins = false;
_called.manualFillRequested = 'none';
let _loginId = -1;
let _singleInputEnabledForPage = false;
const _maximumInputs = 100;
@ -77,14 +76,14 @@ browser.runtime.onMessage.addListener(function(req, sender) {
kpxcDefine.init();
} else if (req.action === 'redetect_fields') {
browser.runtime.sendMessage({
action: 'load_settings',
action: 'load_settings'
}).then((response) => {
kpxc.settings = response;
kpxc.initCredentialFields(true);
});
} else if (req.action === 'show_password_generator') {
kpxcPassword.trigger();
}
}
}
});
@ -344,7 +343,7 @@ kpxcFields.getCombination = function(givenType, fieldId) {
return kpxcFields.combinations[0];
}
for (let c of kpxcFields.combinations) {
for (const c of kpxcFields.combinations) {
if (c[givenType] === fieldId) {
return c;
}
@ -522,7 +521,7 @@ kpxcFields.prepareCombinations = function(combinations) {
pwField.setAttribute('kpxcFields-onChange', true);
pwField.onchange = function() {
this.setAttribute('unchanged', false);
}
};
}
// Initialize form-submit for remembering credentials
@ -699,7 +698,7 @@ kpxcObserverHelper.detectURLChange = function() {
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
// Detects DOM changes in the document
let observer = new MutationObserver(function(mutations, observer) {
const observer = new MutationObserver(function(mutations, obs) {
if (document.visibilityState === 'hidden') {
return;
}
@ -737,7 +736,7 @@ observer.observe(document, {
attributes: true,
childList: true,
characterData: true,
attributeFilter: ['style']
attributeFilter: [ 'style' ]
});
var kpxc = {};
@ -750,7 +749,7 @@ kpxc.credentials = [];
const initcb = function() {
browser.runtime.sendMessage({
action: 'load_settings',
action: 'load_settings'
}).then((response) => {
kpxc.settings = response;
kpxc.initCredentialFields();
@ -855,7 +854,7 @@ kpxc.initCredentialFields = function(forceCall) {
// Get submitUrl for a single input
if (!kpxc.submitUrl && kpxcFields.combinations.length === 1 && inputs.length === 1) {
kpxc.submitUrl = kpxc.getFormActionUrlFromSingleInput(inputs[0]);
}
}
if (kpxc.settings.autoRetrieveCredentials && _called.retrieveCredentials === false && (kpxc.url && kpxc.submitUrl)) {
browser.runtime.sendMessage({
@ -914,7 +913,7 @@ kpxc.retrieveCredentialsCallback = function(credentials, dontAutoFillIn) {
};
kpxc.prepareFieldsForCredentials = function(autoFillInForSingle) {
// only one login for this site
// Only one login for this site
if (autoFillInForSingle && kpxc.settings.autoFillSingleEntry && kpxc.credentials.length === 1) {
let combination = null;
if (!kpxc.p && !kpxc.u && kpxcFields.combinations.length > 0) {
@ -934,22 +933,25 @@ kpxc.prepareFieldsForCredentials = function(autoFillInForSingle) {
if (combination) {
let list = [];
if (kpxc.fillInStringFields(combination.fields, kpxc.credentials[0].stringFields, list)) {
kpxcForm.destroy(false, {'password': list.list[0], 'username': list.list[1]});
kpxcForm.destroy(false, { 'password': list.list[0], 'username': list.list[1] });
}
}
// Generate popup-list of usernames + descriptions
browser.runtime.sendMessage({
action: 'popup_login',
args: [ [ kpxc.credentials[0].login + ' (' + kpxc.credentials[0].name + ')' ]]
args: [ [ kpxc.credentials[0].login + ' (' + kpxc.credentials[0].name + ')' ] ]
});
// Auto-submit
kpxc.p.form.submit();
} else if (kpxc.credentials.length > 1 || (kpxc.credentials.length > 0 && (!kpxc.settings.autoFillSingleEntry || !autoFillInForSingle))) {
kpxc.preparePageForMultipleCredentials(kpxc.credentials);
}
};
kpxc.preparePageForMultipleCredentials = function(credentials) {
// add usernames + descriptions to autocomplete-list and popup-list
// Add usernames + descriptions to autocomplete-list and popup-list
const usernames = [];
kpxcAutocomplete.elements = [];
let visibleLogin;
@ -1102,7 +1104,7 @@ kpxc.fillInFromActiveElement = function(suppressWarnings, passOnly = false) {
kpxc.fillInCredentials(combination, passOnly, suppressWarnings);
};
kpxc.fillInFromActiveElementTOTPOnly = function(suppressWarnings) {
kpxc.fillInFromActiveElementTOTPOnly = function() {
const el = document.activeElement;
kpxcFields.setUniqueId(el);
const fieldId = kpxcFields.prepareId(el.getAttribute('data-kpxc-id'));

View file

@ -35,7 +35,7 @@ kpxcPassword.observer = new IntersectionObserver((entries) => {
// Wait for possible DOM animations
setTimeout(() => {
kpxcPassword.setIconPosition(kpxcPassword.icon, entry.target)
kpxcPassword.setIconPosition(kpxcPassword.icon, entry.target);
}, 500);
}
}
@ -127,7 +127,7 @@ kpxcPassword.createDialog = function() {
}
return;
}
kpxcPassword.created = true;
kpxcPassword.created = true;
const wrapper = kpxcUI.createElement('div', 'kpxc');
const dialog = kpxcUI.createElement('div', 'kpxc kpxc-pwgen-dialog');
@ -307,8 +307,7 @@ kpxcPassword.copyPasswordToClipboard = function() {
$('.kpxc-pwgen-input').select();
try {
return document.execCommand('copy');
}
catch (err) {
} catch (err) {
console.log('Could not copy password to clipboard: ' + err);
}
return false;

View file

@ -1,8 +1,7 @@
'use strict';
// jQuery style wrapper for querySelector()
var $ = function(elem)
{
var $ = function(elem) {
return document.querySelector(elem);
};
@ -35,22 +34,22 @@ kpxcUI.createElement = function(type, classes, attributes, textContent) {
// Enables dragging
document.onmousemove = function(e) {
if (kpxcPassword.selected === kpxcPassword.titleBar) {
const x_pos = e.clientX - kpxcPassword.diffX;
const y_pos = e.clientY - kpxcPassword.diffY;
const xPos = e.clientX - kpxcPassword.diffX;
const yPos = e.clientY - kpxcPassword.diffY;
if (kpxcPassword.selected !== null) {
kpxcPassword.dialog.style.left = x_pos + 'px';
kpxcPassword.dialog.style.top = y_pos + 'px';
kpxcPassword.dialog.style.left = xPos + 'px';
kpxcPassword.dialog.style.top = yPos + 'px';
}
}
if (kpxcDefine.selected === kpxcDefine.dialog) {
const x_pos = e.clientX - kpxcDefine.diffX;
const y_pos = e.clientY - kpxcDefine.diffY;
const xPos = e.clientX - kpxcDefine.diffX;
const yPos = e.clientY - kpxcDefine.diffY;
if (kpxcDefine.selected !== null) {
kpxcDefine.dialog.style.left = x_pos + 'px';
kpxcDefine.dialog.style.top = y_pos + 'px';
kpxcDefine.dialog.style.left = xPos + 'px';
kpxcDefine.dialog.style.top = yPos + 'px';
}
}
};

View file

@ -40,14 +40,14 @@ var matchPatternToRegExp = function(pattern) {
`^${schemeSegment}://${hostSegment}/${pathSegment}$`
);
let match = matchPatternRegExp.exec(pattern);
const match = matchPatternRegExp.exec(pattern);
if (!match) {
throw new TypeError('"${pattern}" is not a valid MatchPattern');
throw new TypeError(`"${pattern}" is not a valid MatchPattern`);
}
let [, scheme, host, path] = match;
let [ , scheme, host, path ] = match;
if (!host) {
throw new TypeError('"${pattern}" does not have a valid host');
throw new TypeError(`"${pattern}" does not have a valid host`);
}
let regex = '^';
@ -96,4 +96,4 @@ var slashNeededForUrl = function(pattern) {
function tr(key, params) {
return browser.i18n.getMessage(key, params);
};
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -52,7 +52,7 @@ options.saveSettingsPromise = function() {
});
});
});
}
};
options.saveSetting = function(name) {
const id = '#' + name;
@ -84,7 +84,7 @@ options.saveKeyRing = function() {
options.initGeneralSettings = function() {
$('#tab-general-settings input[type=checkbox]').each(function() {
$(this).attr('checked', options.settings[$(this).attr('name')]);
if ($(this).attr('name') === 'defaultGroupAlwaysAsk' && $(this).attr('checked')) {
if ($(this).attr('name') === 'defaultGroupAlwaysAsk' && $(this).attr('checked')) {
$('#defaultGroup').prop('disabled', true);
$('#defaultGroupButton').prop('disabled', true);
$('#defaultGroupButtonReset').prop('disabled', true);
@ -107,7 +107,7 @@ options.initGeneralSettings = function() {
$('#defaultGroupButton').prop('disabled', false);
$('#defaultGroupButtonReset').prop('disabled', false);
}
} else if (name == 'automaticReconnect') {
} else if (name === 'automaticReconnect') {
const message = updated.automaticReconnect ? 'enable_automatic_reconnect' : 'disable_automatic_reconnect';
browser.runtime.sendMessage({ action: message });
}
@ -253,12 +253,12 @@ options.initConnectedDatabases = function() {
const trClone = $('#tab-connected-databases table tr.clone:first').clone(true);
trClone.removeClass('clone');
for (let hash in options.keyRing) {
for (const hash in options.keyRing) {
const tr = trClone.clone(true);
tr.data('hash', hash);
tr.attr('id', 'tr-cd-' + hash);
$('a.dropdown-toggle:first img:first', tr).attr('src', '/icons/19x19/icon_normal_19x19.png');
$('a.dropdown-toggle:first img:first', tr).attr('src', '/icons/toolbar/icon_normal.png');
tr.children('td:first').text(options.keyRing[hash].id);
tr.children('td:eq(1)').text(options.getPartiallyHiddenKey(options.keyRing[hash].key));
@ -448,7 +448,7 @@ options.initSitePreferences = function() {
trClone.removeClass('clone');
let counter = 1;
if (options.settings['sitePreferences']) {
for (let site of options.settings['sitePreferences']) {
for (const site of options.settings['sitePreferences']) {
const tr = trClone.clone(true);
tr.data('url', site.url);
tr.attr('id', 'tr-scf' + counter);

View file

@ -57,7 +57,7 @@ $(function() {
$('#reopen-database-button').click(function() {
browser.runtime.sendMessage({
action: 'get_status',
args: [ false, true ] // Set forcePopup to true
args: [ false, true ] // Set forcePopup to true
}).then(statusResponse);
});

View file

@ -3,7 +3,7 @@
const getLoginData = function() {
return new Promise((resolve, reject) => {
browser.runtime.getBackgroundPage().then((global) => {
browser.tabs.query({'active': true, 'currentWindow': true}).then((tabs) => {
browser.tabs.query({ 'active': true, 'currentWindow': true }).then((tabs) => {
resolve(global.page.tabs[tabs[0].id].loginList);
});
});

View file

@ -161,8 +161,8 @@ function _initialize(tab) {
.attr('class', 'list-group-item')
.text(_tab.credentials.list[i].login + ' (' + _tab.credentials.list[i].name + ')')
.data('entryId', i)
.click(function(e) {
e.preventDefault();
.click(function(ev) {
ev.preventDefault();
const entryId = $(this).data('entryId');
// Use the current username if it's empty
@ -189,7 +189,7 @@ function _initialize(tab) {
browser.runtime.sendMessage({
action: 'update_credentials',
args: [_tab.credentials.list[entryId].uuid, _tab.credentials.username, _tab.credentials.password, _tab.credentials.url]
args: [ _tab.credentials.list[entryId].uuid, _tab.credentials.username, _tab.credentials.password, _tab.credentials.url ]
}).then(_verifyResult);
});
});
@ -277,7 +277,7 @@ const getDefaultGroup = function(groups, defaultGroup) {
$(function() {
browser.runtime.sendMessage({
action: 'stack_add',
args: [ 'icon_remember_red_background_19x19.png', 'popup_remember.html', 10, true, 0 ]
args: [ 'icon_remember_red_background.png', 'popup_remember.html', 10, true, 0 ]
});
browser.runtime.sendMessage({

View file

@ -5,7 +5,7 @@ for (const item of items) {
let key = item.getAttribute('data-i18n');
if (key) {
let attr = '';
[ attr, key] = trAttribute(key);
[ attr, key ] = trAttribute(key);
const placeholder = item.getAttribute('i18n-placeholder');
const translation = placeholder ? browser.i18n.getMessage(key, placeholder) : browser.i18n.getMessage(key);
@ -31,4 +31,4 @@ function trAttribute(key) {
}
return [ attr, key ];
};
}