1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

send message to safari tab for autofill

This commit is contained in:
Kyle Spearrin
2018-01-12 14:44:44 -05:00
parent ca5026429a
commit 0a056a3941
5 changed files with 51 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
!(function () {
!(function () {
/*
1Password Extension
@@ -994,6 +994,26 @@
End 1Password Extension
*/
if ((typeof safari !== 'undefined')) {
safari.self.addEventListener('bitwarden', function (msgEvent) {
var msg = msgEvent.message;
if (msg.command === 'collectPageDetails') {
var pageDetails = collect(document);
var pageDetailsObj = JSON.parse(pageDetails);
safari.self.tab.dispatchMessage('bitwarden', {
command: 'collectPageDetailsResponse',
tab: msg.tab,
details: pageDetailsObj,
sender: msg.sender
});
}
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);