Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marius-wieschollek/passwords-webextension.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorM. Wieschollek <passwords.public@mdns.eu>2021-02-27 14:24:05 +0300
committerGitHub <noreply@github.com>2021-02-27 14:24:05 +0300
commit9c5af131d3a4c493bd9337d67e1c3b3e906f38c7 (patch)
tree7925b7a3568677dc6f2575aeea03540378d85b65 /src/js
parent5505d4534d4ade5ab36c1581c825aeb697a61778 (diff)
parent4e22a874f616f31ef04b1e795b45669b4589480c (diff)
Merge pull request #152 from flo-mic/patch-1
fix autofill not working on page load
Diffstat (limited to 'src/js')
-rw-r--r--src/js/App/Client.js2
-rw-r--r--src/js/Manager/AutofillManager.js65
-rw-r--r--src/js/Services/MessageService.js2
3 files changed, 60 insertions, 9 deletions
diff --git a/src/js/App/Client.js b/src/js/App/Client.js
index 61b987b..4057278 100644
--- a/src/js/App/Client.js
+++ b/src/js/App/Client.js
@@ -3,6 +3,7 @@ import ErrorManager from '@js/Manager/ErrorManager';
import MessageService from '@js/Services/MessageService';
import ConverterManager from '@js/Manager/ConverterManager';
import ClientControllerManager from '@js/Manager/ClientControllerManager';
+import AutofillManager from '@js/Manager/AutofillManager';
import DomMiner from '@js/Miner/DomMiner';
class Client {
@@ -17,6 +18,7 @@ class Client {
ClientControllerManager.init();
let miner = new DomMiner();
miner.init();
+ AutofillManager.initClient();
} catch(e) {
ErrorManager.logError(e);
}
diff --git a/src/js/Manager/AutofillManager.js b/src/js/Manager/AutofillManager.js
index 7b4e141..16f122c 100644
--- a/src/js/Manager/AutofillManager.js
+++ b/src/js/Manager/AutofillManager.js
@@ -8,15 +8,54 @@ export default new class AutofillManager {
constructor() {
this._recommendationListener = (recommendations) => {
- this._sendAutofillPassword(recommendations);
+ this.recommendations = recommendations;
+ this.currentURL =TabManager.getAll()[TabManager.currentTabId].url
};
+ this.recommendations = [];
+ this.currentURL = null;
}
/**
*
*/
- init() {
+ async init() {
RecommendationManager.listen.on(this._recommendationListener);
+ MessageService.listen(
+ 'autofill.page.ready',
+ (message, reply) => {
+ if(message.url = this.currentURL) {
+ this._sendAutofillPassword(this.recommendations);
+ }
+ }
+ );
+ }
+
+ /**
+ *
+ */
+ initClient() {
+ if (document.readyState === "complete"
+ || document.readyState === "loaded"
+ || document.readyState === "interactive") {
+ this._sendBrowserPageReadyMessage()
+ } else {
+ window.addEventListener("domcontentloaded", this._sendBrowserPageReadyMessage());
+ }
+ }
+
+ /**
+ *
+ */
+ _sendBrowserPageReadyMessage() {
+ MessageService.send(
+ {
+ type : 'autofill.page.ready',
+ payload : {
+ url: window.location.href
+ },
+ receiver: 'background'
+ }
+ );
}
/**
@@ -28,12 +67,22 @@ export default new class AutofillManager {
if(recommendations.length === 0 || await SettingsService.getValue('paste.autofill') === false) return;
let password = recommendations[0];
- let ids = TabManager.get('autofill.ids', []);
- if(ids.indexOf(password.getId()) === -1) {
- ids.push(password.getId());
- TabManager.set('autofill.ids', ids);
- }
+ setTimeout(() => {
+ let ids = TabManager.get('autofill.ids', []);
+ if(ids.indexOf(password.getId()) === -1) {
+ ids.push(password.getId());
+ TabManager.set('autofill.ids', ids);
+ }
+ this._sendPwdToMessageService(password);
+ }, 500);
+ }
+ /**
+ *
+ * @param {Password[]} recommendations
+ * @private
+ */
+ _sendPwdToMessageService(password) {
MessageService.send(
{
type : 'autofill.password',
@@ -49,4 +98,4 @@ export default new class AutofillManager {
}
).catch(ErrorManager.catchEvt);
}
-}; \ No newline at end of file
+};
diff --git a/src/js/Services/MessageService.js b/src/js/Services/MessageService.js
index 79b18b1..461390e 100644
--- a/src/js/Services/MessageService.js
+++ b/src/js/Services/MessageService.js
@@ -292,7 +292,7 @@ class MessageService {
*/
_checkClientRestrictions(message) {
return message.getSender() !== 'client' ||
- (message.getType() !== 'password.mine' && message.getType() !== 'queue.items' && message.getType() !== 'debug.form.fields') ||
+ (message.getType() !== 'password.mine' && message.getType() !== 'queue.items' && message.getType() !== 'debug.form.fields' && message.getType() !== 'autofill.page.ready') ||
(message.getType() === 'queue.items' && message.getPayload().name !== 'error');
}