mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-28 12:45:45 +01:00
Remove safari only code from autofill.
This commit is contained in:
parent
a9c9108053
commit
9fb80823ba
@ -989,35 +989,6 @@
|
||||
End 1Password Extension
|
||||
*/
|
||||
|
||||
if ((typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 &&
|
||||
navigator.userAgent.indexOf('Chrome') === -1) {
|
||||
if (window.__bitwardenFrameId == null) {
|
||||
window.__bitwardenFrameId = Math.floor(Math.random() * Math.floor(99999999));
|
||||
}
|
||||
safari.self.addEventListener('message', function (msgEvent) {
|
||||
var msg = JSON.parse(msgEvent.message.msg);
|
||||
if (msg.bitwardenFrameId != null && window.__bitwardenFrameId !== msg.bitwardenFrameId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.command === 'collectPageDetails') {
|
||||
var pageDetails = collect(document);
|
||||
var pageDetailsObj = JSON.parse(pageDetails);
|
||||
safari.extension.dispatchMessage('bitwarden', {
|
||||
command: 'collectPageDetailsResponse',
|
||||
tab: msg.tab,
|
||||
details: pageDetailsObj,
|
||||
sender: msg.sender,
|
||||
bitwardenFrameId: window.__bitwardenFrameId
|
||||
});
|
||||
}
|
||||
else if (msg.command === 'fillForm') {
|
||||
fill(document, msg.fillScript);
|
||||
}
|
||||
}, false);
|
||||
return;
|
||||
}
|
||||
|
||||
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
||||
if (msg.command === 'collectPageDetails') {
|
||||
var pageDetails = collect(document);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -20,7 +20,6 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
let disabledAddLoginNotification = false;
|
||||
let disabledChangedPasswordNotification = false;
|
||||
|
||||
|
||||
chrome.storage.local.get('neverDomains', (ndObj: any) => {
|
||||
const domains = ndObj.neverDomains;
|
||||
if (domains != null && domains.hasOwnProperty(window.location.hostname)) {
|
||||
|
@ -45,11 +45,6 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
shortcut: shortcut,
|
||||
};
|
||||
|
||||
if (isSafari) {
|
||||
msg.bitwardenFrameId = (window as any).__bitwardenFrameId;
|
||||
safari.extension.dispatchMessage('bitwarden', msg);
|
||||
} else {
|
||||
chrome.runtime.sendMessage(msg);
|
||||
}
|
||||
chrome.runtime.sendMessage(msg);
|
||||
}
|
||||
});
|
||||
|
@ -68,8 +68,6 @@ export class PopupUtilsService {
|
||||
chrome.tabs.create({
|
||||
url: href,
|
||||
});
|
||||
} else if ((typeof safari !== 'undefined')) {
|
||||
// Safari can't open popup in full page tab :(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user