mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Fixed saving Dates with local storage and Chrome/Chromium
This commit is contained in:
parent
b78ee812e6
commit
b1b5e3642e
6 changed files with 23 additions and 15 deletions
|
|
@ -110,14 +110,14 @@ event.onLoadSettings = function(callback, tab) {
|
|||
|
||||
event.onLoadKeyRing = function(callback, tab) {
|
||||
browser.storage.local.get({'keyRing': {}}).then(function(item) {
|
||||
keepass.keyRing = item.keyRing;
|
||||
keepass.keyRing = JSON.parse(item.keyRing);
|
||||
if (keepass.isAssociated() && !keepass.keyRing[keepass.associated.hash]) {
|
||||
keepass.associated = {
|
||||
"value": false,
|
||||
"hash": null
|
||||
};
|
||||
}
|
||||
callback(item.keyRing);
|
||||
callback(JSON.parse(item.keyRing));
|
||||
}, (err) => {
|
||||
console.log('error loading keyRing: ' + err);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ keepass.migrateKeyRing().then(() => {
|
|||
page.initOpenedTabs();
|
||||
|
||||
// set initial tab-ID
|
||||
browser.tabs.query({"active": true, "currentWindow": true}).then(function(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;
|
||||
|
|
@ -126,7 +126,7 @@ for (const item of contextMenuItems) {
|
|||
// Listen for keyboard shortcuts specified by user
|
||||
browser.commands.onCommand.addListener((command) => {
|
||||
if (command === 'fill-username-password') {
|
||||
browser.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
||||
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
||||
if (tabs.length) {
|
||||
browser.tabs.sendMessage(tabs[0].id, { action: 'fill_user_pass' });
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ browser.commands.onCommand.addListener((command) => {
|
|||
}
|
||||
|
||||
if (command === 'fill-password') {
|
||||
browser.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
||||
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
||||
if (tabs.length) {
|
||||
browser.tabs.sendMessage(tabs[0].id, { action: 'fill_pass_only' });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ browser.storage.local.get({
|
|||
'latestKeePassXC': {'version': 0, 'versionParsed': 0, 'lastChecked': null},
|
||||
'keyRing': {}})
|
||||
.then((item) => {
|
||||
keepass.latestKeePassHttp = item.latestKeePassHttp;
|
||||
keepass.keyRing = item.keyRing;
|
||||
keepass.latestKeePassXC = item.latestKeePassXC;
|
||||
keepass.keyRing = JSON.parse(item.keyRing);
|
||||
});
|
||||
|
||||
keepass.addCredentials = function(callback, tab, username, password, url) {
|
||||
|
|
@ -562,17 +562,17 @@ keepass.isAssociated = function() {
|
|||
keepass.migrateKeyRing = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
browser.storage.local.get('keyRing').then((item) => {
|
||||
var keyring = item.keyRing;
|
||||
let keyring = item.keyRing;
|
||||
if ('keyRing' in localStorage) {
|
||||
if (!keyring) {
|
||||
keyring = JSON.parse(localStorage['keyRing']);
|
||||
browser.storage.local.set({'keyRing': keyring});
|
||||
browser.storage.local.set({'keyRing': JSON.stringify(keyring)});
|
||||
}
|
||||
delete localStorage['keyRing'];
|
||||
}
|
||||
if (keepass.keyId in localStorage && keepass.keyBody in localStorage) {
|
||||
if (!keyring) {
|
||||
var hash = keepass.getDatabaseHash(null);
|
||||
const hash = keepass.getDatabaseHash(null);
|
||||
keepass.saveKey(hash, localStorage[keepass.keyId], localStorage[keepass.keyBody]);
|
||||
}
|
||||
delete localStorage[keepass.keyId];
|
||||
|
|
@ -598,19 +598,19 @@ keepass.saveKey = function(hash, id, key) {
|
|||
keepass.keyRing[hash].key = key;
|
||||
keepass.keyRing[hash].hash = hash;
|
||||
}
|
||||
browser.storage.local.set({'keyRing': keepass.keyRing});
|
||||
browser.storage.local.set({'keyRing': JSON.stringify(keepass.keyRing)});
|
||||
}
|
||||
|
||||
keepass.updateLastUsed = function(hash) {
|
||||
if ((hash in keepass.keyRing)) {
|
||||
keepass.keyRing[hash].lastUsed = new Date();
|
||||
browser.storage.local.set({'keyRing': keepass.keyRing});
|
||||
browser.storage.local.set({'keyRing': JSON.stringify(keepass.keyRing)});
|
||||
}
|
||||
}
|
||||
|
||||
keepass.deleteKey = function(hash) {
|
||||
delete keepass.keyRing[hash];
|
||||
browser.storage.local.set({'keyRing': keepass.keyRing});
|
||||
browser.storage.local.set({'keyRing': JSON.stringify(keepass.keyRing)});
|
||||
}
|
||||
|
||||
keepass.setcurrentKeePassXCVersion = function(version) {
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ page.createTabEntry = function(tabId) {
|
|||
page.removePageInformationFromNotExistingTabs = function() {
|
||||
let rand = Math.floor(Math.random()*1001);
|
||||
if (rand === 28) {
|
||||
browser.tabs.query({}, (tabs) => {
|
||||
browser.tabs.query({}).then(function(tabs) {
|
||||
let $tabIds = {};
|
||||
const $infoIds = Object.keys(page.tabs);
|
||||
|
||||
|
|
|
|||
|
|
@ -1701,10 +1701,18 @@ cipEvents.triggerActivatedTab = function() {
|
|||
// Detect div's that include forms and are visible
|
||||
$(function() {
|
||||
const divDetect = setInterval(function() {
|
||||
/*browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
||||
const fields = cipFields.getAllFields();
|
||||
if (fields.length > 0) {
|
||||
cip.initCredentialFields(true);
|
||||
clearInterval(divDetect);
|
||||
}
|
||||
});*/
|
||||
const fields = cipFields.getAllFields();
|
||||
if (fields.length > 0) {
|
||||
cip.initCredentialFields(true);
|
||||
clearInterval(divDetect);
|
||||
}
|
||||
console.log("Check..");
|
||||
}, 1000);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ options.saveSettings = function() {
|
|||
};
|
||||
|
||||
options.saveKeyRing = function() {
|
||||
browser.storage.local.set({'keyRing': options.keyRing});
|
||||
browser.storage.local.set({'keyRing': JSON.stringify(options.keyRing)});
|
||||
browser.runtime.sendMessage({
|
||||
action: 'load_keyring'
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue