mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
delayed autofill attempt
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
document.addEventListener('DOMContentLoaded', (event) => {
|
document.addEventListener('DOMContentLoaded', (event) => {
|
||||||
let pageHref: string = null;
|
let pageHref: string = null;
|
||||||
|
let filledThisHref = false;
|
||||||
|
let delayFillTimeout: number;
|
||||||
|
|
||||||
const isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 &&
|
const isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 &&
|
||||||
navigator.userAgent.indexOf('Chrome') === -1;
|
navigator.userAgent.indexOf('Chrome') === -1;
|
||||||
|
|
||||||
@@ -12,7 +15,9 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||||||
safari.self.addEventListener('message', (msgEvent: any) => {
|
safari.self.addEventListener('message', (msgEvent: any) => {
|
||||||
const msg = msgEvent.message;
|
const msg = msgEvent.message;
|
||||||
if (msg.command === responseCommand && msg.data.autofillEnabled === true) {
|
if (msg.command === responseCommand && msg.data.autofillEnabled === true) {
|
||||||
setInterval(doFillIfNeeded, 500);
|
setInterval(() => doFillIfNeeded(), 500);
|
||||||
|
} else if (msg.command === 'fillForm' && pageHref === msg.url) {
|
||||||
|
filledThisHref = true;
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
return;
|
return;
|
||||||
@@ -20,13 +25,32 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||||||
const enabledKey = 'enableAutoFillOnPageLoad';
|
const enabledKey = 'enableAutoFillOnPageLoad';
|
||||||
chrome.storage.local.get(enabledKey, (obj: any) => {
|
chrome.storage.local.get(enabledKey, (obj: any) => {
|
||||||
if (obj != null && obj[enabledKey] === true) {
|
if (obj != null && obj[enabledKey] === true) {
|
||||||
setInterval(doFillIfNeeded, 500);
|
setInterval(() => doFillIfNeeded(), 500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
chrome.runtime.onMessage.addListener((msg: any, sender: any, sendResponse: Function) => {
|
||||||
|
if (msg.command === 'fillForm' && pageHref === msg.url) {
|
||||||
|
filledThisHref = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function doFillIfNeeded() {
|
function doFillIfNeeded(force: boolean = false) {
|
||||||
if (pageHref !== window.location.href) {
|
if (force || pageHref !== window.location.href) {
|
||||||
|
if (!force) {
|
||||||
|
// Some websites are slow and rendering all page content. Try to fill again later
|
||||||
|
// if we haven't already.
|
||||||
|
filledThisHref = false;
|
||||||
|
if (delayFillTimeout != null) {
|
||||||
|
window.clearTimeout(delayFillTimeout);
|
||||||
|
}
|
||||||
|
delayFillTimeout = window.setTimeout(() => {
|
||||||
|
if (!filledThisHref) {
|
||||||
|
doFillIfNeeded(true);
|
||||||
|
}
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
|
||||||
pageHref = window.location.href;
|
pageHref = window.location.href;
|
||||||
const msg = {
|
const msg = {
|
||||||
command: 'bgCollectPageDetails',
|
command: 'bgCollectPageDetails',
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
BrowserApi.tabSendMessage(tab, {
|
BrowserApi.tabSendMessage(tab, {
|
||||||
command: 'fillForm',
|
command: 'fillForm',
|
||||||
fillScript: fillScript,
|
fillScript: fillScript,
|
||||||
|
url: tab.url,
|
||||||
}, { frameId: pd.frameId });
|
}, { frameId: pd.frameId });
|
||||||
|
|
||||||
if (options.cipher.type !== CipherType.Login || totpPromise || options.skipTotp ||
|
if (options.cipher.type !== CipherType.Login || totpPromise || options.skipTotp ||
|
||||||
|
|||||||
Reference in New Issue
Block a user