mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 09:43:23 +00:00
Remove safari only code from autofill.
This commit is contained in:
@@ -3,44 +3,17 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
let filledThisHref = false;
|
||||
let delayFillTimeout: number;
|
||||
|
||||
const isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 &&
|
||||
navigator.userAgent.indexOf('Chrome') === -1;
|
||||
|
||||
if (isSafari) {
|
||||
if ((window as any).__bitwardenFrameId == null) {
|
||||
(window as any).__bitwardenFrameId = Math.floor(Math.random() * Math.floor(99999999));
|
||||
const enabledKey = 'enableAutoFillOnPageLoad';
|
||||
chrome.storage.local.get(enabledKey, (obj: any) => {
|
||||
if (obj != null && obj[enabledKey] === true) {
|
||||
setInterval(() => doFillIfNeeded(), 500);
|
||||
}
|
||||
const responseCommand = 'autofillerAutofillOnPageLoadEnabledResponse';
|
||||
safari.extension.dispatchMessage('bitwarden', {
|
||||
command: 'bgGetDataForTab',
|
||||
responseCommand: responseCommand,
|
||||
bitwardenFrameId: (window as any).__bitwardenFrameId,
|
||||
});
|
||||
safari.self.addEventListener('message', (msgEvent: any) => {
|
||||
const msg = JSON.parse(msgEvent.message.msg);
|
||||
if (msg.bitwardenFrameId != null && (window as any).__bitwardenFrameId !== msg.bitwardenFrameId) {
|
||||
return;
|
||||
}
|
||||
if (msg.command === responseCommand && msg.data.autofillEnabled === true) {
|
||||
setInterval(() => doFillIfNeeded(), 500);
|
||||
} else if (msg.command === 'fillForm' && pageHref === msg.url) {
|
||||
filledThisHref = true;
|
||||
}
|
||||
}, false);
|
||||
return;
|
||||
} else {
|
||||
const enabledKey = 'enableAutoFillOnPageLoad';
|
||||
chrome.storage.local.get(enabledKey, (obj: any) => {
|
||||
if (obj != null && obj[enabledKey] === true) {
|
||||
setInterval(() => doFillIfNeeded(), 500);
|
||||
}
|
||||
});
|
||||
chrome.runtime.onMessage.addListener((msg: any, sender: any, sendResponse: Function) => {
|
||||
if (msg.command === 'fillForm' && pageHref === msg.url) {
|
||||
filledThisHref = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
chrome.runtime.onMessage.addListener((msg: any, sender: any, sendResponse: Function) => {
|
||||
if (msg.command === 'fillForm' && pageHref === msg.url) {
|
||||
filledThisHref = true;
|
||||
}
|
||||
});
|
||||
|
||||
function doFillIfNeeded(force: boolean = false) {
|
||||
if (force || pageHref !== window.location.href) {
|
||||
@@ -64,12 +37,7 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
sender: 'autofiller',
|
||||
};
|
||||
|
||||
if (isSafari) {
|
||||
msg.bitwardenFrameId = (window as any).__bitwardenFrameId;
|
||||
safari.extension.dispatchMessage('bitwarden', msg);
|
||||
} else {
|
||||
chrome.runtime.sendMessage(msg);
|
||||
}
|
||||
chrome.runtime.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user