Some minor changes, mostly related to Firefox

This commit is contained in:
varjolintu 2017-07-29 10:26:16 +03:00
parent 5dff6ce258
commit 9f030df327
12 changed files with 51 additions and 52 deletions

View file

@ -1,3 +1,7 @@
0.2.7 (2017-??-??)
=========================
- Some Firefox related changes (credits to projectgus)
0.2.6 (2017-07-23)
=========================
- Fixed error message variables

View file

@ -2,10 +2,17 @@
Chrome extension for [KeePassXC](https://keepassxc.org/) with Native Messaging.
This is a heavily forked version of [pfn](https://github.com/pfn)'s [chromeIPass](https://github.com/pfn/passifox).
Some changes merged also from [projectgus'](https://github.com/projectgus/passifox) fork.
For testing purposes, please use following unofficial KeePassXC [release's](https://github.com/varjolintu/keepassxc/releases).
Get the extension for [Firefox](https://addons.mozilla.org/en-US/firefox/addon/keepassxc-browser/) or [Chrome/Chromium](https://chrome.google.com/webstore/detail/keepassxc-browser/iopaggbpplllidnfmcghoonnokmjoicf).
If you want to use the extension manually with the latest stable build of Firefox, you can do the following:
- Install [Firefox Nightly](https://www.mozilla.org/en-US/firefox/channel/desktop/#nightly)
- Download the .crx file from [releases](https://github.com/varjolintu/keepassxc-browser/releases)
- Drag the .crx to the Firefox's Add-ons page (about:addons)
- Close Firefox Nightly and start the stable Firefox. The add-on should be now installed
## How it works
There are two methods which you can use keepassxc-browser to connect to KeePassXC:

View file

@ -5,6 +5,7 @@
"type": "stdio",
"allowed_origins": [
"chrome-extension://iopaggbpplllidnfmcghoonnokmjoicf/",
"chrome-extension://fhakpkpdnjecjfceboihdjpfmgajebii/"
"chrome-extension://fhakpkpdnjecjfceboihdjpfmgajebii/",
"chrome-extension://jaikbblhommnkeialomogohhdlndpfbi/"
]
}

View file

@ -5,6 +5,7 @@
"type": "stdio",
"allowed_origins": [
"chrome-extension://iopaggbpplllidnfmcghoonnokmjoicf/",
"chrome-extension://fhakpkpdnjecjfceboihdjpfmgajebii/"
"chrome-extension://fhakpkpdnjecjfceboihdjpfmgajebii/",
"chrome-extension://jaikbblhommnkeialomogohhdlndpfbi/"
]
}

View file

@ -44,11 +44,6 @@ event.invoke = function(handler, callback, senderTabId, args, secondTime) {
page.removePageInformationFromNotExistingTabs();
browser.tabs.get(senderTabId, (tab) => {
//browser.tabs.query({'active': true, 'windowId': browser.windows.WINDOW_ID_CURRENT}, function(tabs) {
//if (tabs.length === 0)
// return; // For example: only the background devtools or a popup are opened
//var tab = tabs[0];
if (!tab) {
return;
}
@ -260,6 +255,5 @@ event.messageHandlers = {
'stack_add': browserAction.stackAdd,
'update_available_keepassxc': event.onUpdateAvailableKeePassXC,
'generate_password': keepass.generatePassword,
'copy_password': keepass.copyPassword,
'reconnect': event.onReconnect
};

View file

@ -10,7 +10,9 @@ keepass.changePublicKeys(null, (pkRes) => {
window.browser = (function () { return window.msBrowser || window.browser || window.chrome; })();
// Set initial tab-ID
browser.tabs.query({'active': true, 'windowId': browser.windows.WINDOW_ID_CURRENT}, (tabs) => {
//browser.tabs.query({'active': true, 'windowId': browser.windows.WINDOW_ID_CURRENT}, (tabs) => {
browser.tabs.query({"active": true, "currentWindow": true}, (tabs) => {
//browser.tabs.query({"active": true, "currentWindow": true}).then((tabs) => {
if (tabs.length === 0)
return; // For example: only the background devtools or a popup are opened
page.currentTabId = tabs[0].id;
@ -80,9 +82,11 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
});
// Retrieve Credentials and try auto-login for HTTPAuth requests
browser.webRequest.onAuthRequired.addListener(httpAuth.handleRequest,
{ urls: ['<all_urls>'] }, ['asyncBlocking']
);
if (browser.webRequest.onAuthRequired) {
browser.webRequest.onAuthRequired.addListener(httpAuth.handleRequest,
{ urls: ['<all_urls>'] }, ['asyncBlocking']
);
}
browser.runtime.onMessage.addListener(event.onMessage);

View file

@ -273,30 +273,6 @@ keepass.generatePassword = function (callback, tab, forceCallback) {
}, tab);
}
keepass.copyPassword = function(callback, tab, password) {
browser.runtime.getBackgroundPage((bg) => {
let c2c = bg.document.getElementById('copy2clipboard');
if (!c2c) {
let input = document.createElement('input');
input.type = 'text';
input.id = 'copy2clipboard';
bg.document.getElementsByTagName('body')[0].appendChild(input);
c2c = bg.document.getElementById('copy2clipboard');
}
c2c.value = password;
c2c.select();
try {
document.execCommand('copy');
c2c.value = '';
callback(true);
}
catch (err) {
console.log('Could not copy password to clipboard: ' + err);
}
});
}
keepass.associate = function(callback, tab) {
if (keepass.isAssociated()) {
return;
@ -654,7 +630,7 @@ keepass.checkForNewKeePassXCVersion = function() {
};
xhr.onerror = function(e) {
console.log('checkForNewKeePassXCVersion error: ${e}');
console.log('checkForNewKeePassXCVersion error:' + e);
}
xhr.send();

View file

@ -271,10 +271,7 @@ cipPassword.createDialog = function() {
id: 'cip-genpw-btn-clipboard',
click: (e) => {
e.preventDefault();
browser.runtime.sendMessage({
action: 'copy_password',
args: [jQuery('input#cip-genpw-textfield-password').val()]
}, cipPassword.callbackPasswordCopied);
cipPassword.copyPasswordToClipboard();
}
},
'Fill & copy':
@ -309,11 +306,7 @@ cipPassword.createDialog = function() {
}
}
// Copy password to clipboard
browser.runtime.sendMessage({
action: 'copy_password',
args: [$password]
}, cipPassword.callbackPasswordCopied);
cipPassword.copyPasswordToClipboard();
}
}
}
@ -381,6 +374,26 @@ cipPassword.setIconPosition = function($icon, $field) {
.css('left', $field.offset().left + $field.outerWidth() - $icon.data('size') - $icon.data('offset'))
}
cipPassword.copyPasswordToClipboard = function(e) {
if (e) {
e.preventDefault();
}
const input = jQuery("input#cip-genpw-textfield-password");
input.select()
try {
const success = document.execCommand('copy');
if (success) {
jQuery("#cip-genpw-btn-clipboard").addClass("b2c-btn-success");
}
jQuery("#cip-genpw-dialog").select();
input.value = '';
}
catch (err) {
console.log('Could not copy password to clipboard: ' + err);
}
}
cipPassword.callbackPasswordCopied = function(bool) {
if (bool) {
jQuery('#cip-genpw-btn-clipboard').addClass('btn-success');

View file

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "keepassxc-browser",
"version": "0.2.6",
"version": "0.2.7",
"description": "KeePassXC integration for modern web browsers",
"author": "Sami Vänttinen",
"icons": {
@ -74,7 +74,7 @@
"applications": {
"gecko": {
"id": "keepassxc-browser@sami.vanttinen",
"strict_min_version": "56.0a1"
"strict_min_version": "54.0"
}
}
}

View file

@ -36,7 +36,7 @@ options.saveSetting = function(name) {
localStorage.settings = JSON.stringify(options.settings);
chrome.extension.sendMessage({
browser.runtime.sendMessage({
action: 'load_settings'
});
}

View file

@ -2,8 +2,7 @@ window.browser = (function () { return window.msBrowser || window.browser || win
$(function() {
browser.runtime.getBackgroundPage(function(global) {
browser.tabs.query(null, (tab) => {
//const data = global.tab_httpauth_list['tab' + tab.id];
browser.tabs.query({"active": true, "currentWindow": true}, (tab) => {
const data = global.page.tabs[tab.id].loginList;
let ul = document.getElementById('login-list');
for (let i = 0; i < data.logins.length; i++) {

View file

@ -2,7 +2,7 @@ window.browser = (function () { return window.msBrowser || window.browser || win
$(function() {
browser.runtime.getBackgroundPage(function(global) {
browser.tabs.query({'active': true, 'windowId': browser.windows.WINDOW_ID_CURRENT}, function(tabs) {
browser.tabs.query({"active": true, "currentWindow": true}, (tabs) => {
if (tabs.length === 0)
return; // For example: only the background devtools or a popup are opened
const tab = tabs[0];