From 971d5e5e428c2897be219743faa4507d092fe471 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Mon, 11 Sep 2017 18:04:39 +0300 Subject: [PATCH] More various fixes --- keepassxc-browser/background/init.js | 18 ++++++----------- keepassxc-browser/background/page.js | 22 +++++++++++++++----- keepassxc-browser/keepassxc-browser.js | 28 +++++++++----------------- 3 files changed, 32 insertions(+), 36 deletions(-) diff --git a/keepassxc-browser/background/init.js b/keepassxc-browser/background/init.js index 204dbfd..5b1ca27 100644 --- a/keepassxc-browser/background/init.js +++ b/keepassxc-browser/background/init.js @@ -6,18 +6,12 @@ keepass.migrateKeyRing().then(() => { keepass.connectToNative(); keepass.generateNewKeyPair(); keepass.changePublicKeys(null, (pkRes) => { - keepass.getDatabaseHash((gdRes) => { - // create tab information structure for every opened tab - page.initOpenedTabs(); - - // set initial tab-ID - 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; - browserAction.show(null, tabs[0]); - }); - }, null); + // create tab information structure for every opened tab + page.initOpenedTabs().then(() => { + keepass.getDatabaseHash((gdRes) => { + + }, null); + }); }); }); }); diff --git a/keepassxc-browser/background/page.js b/keepassxc-browser/background/page.js index ee3a201..7044c6a 100644 --- a/keepassxc-browser/background/page.js +++ b/keepassxc-browser/background/page.js @@ -12,7 +12,6 @@ var page = {}; page.tabs = {}; page.currentTabId = -1; -page.settings = (typeof(localStorage.settings) === 'undefined') ? {} : JSON.parse(localStorage.settings); page.blockedTabs = {}; page.migrateSettings = () => { @@ -64,10 +63,23 @@ page.initSettings = function() { } page.initOpenedTabs = function() { - browser.tabs.query({}).then((tabs) => { - for (const i of tabs) { - page.createTabEntry(i.id); - } + return new Promise((resolve, reject) => { + browser.tabs.query({}).then(function (tabs) { + for (var i = 0; i < tabs.length; i++) { + page.createTabEntry(tabs[i].id); + } + + // set initial tab-ID + browser.tabs.query({ "active": true, "currentWindow": true }).then(function (tabs) { + if (tabs.length === 0) { + resolve(); + return; // For example: only the background devtools or a popup are opened + } + page.currentTabId = tabs[0].id; + browserAction.show(null, tabs[0]); + resolve(); + }); + }); }); } diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js index e00ca3e..b117598 100644 --- a/keepassxc-browser/keepassxc-browser.js +++ b/keepassxc-browser/keepassxc-browser.js @@ -1098,6 +1098,15 @@ cip.credentials = []; jQuery(function() { cip.init(); + + // Detect div's that include forms and are visible + const divDetect = setInterval(function() { + const fields = cipFields.getAllFields(); + if (fields.length > 0) { + cip.initCredentialFields(true); + clearInterval(divDetect); + } + }, 1000); }); cip.init = function() { @@ -1697,22 +1706,3 @@ cipEvents.triggerActivatedTab = function() { }).then(cip.retrieveCredentialsCallback); } } - -// 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); -});