1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 15:23:33 +00:00

Revert "Safari Web Extension Port from App Extension"

This commit is contained in:
Chad Scharf
2021-01-13 17:08:33 -05:00
committed by GitHub
parent ebd2439edd
commit 336f8f3117
47 changed files with 1950 additions and 664 deletions

View File

@@ -3,21 +3,34 @@ require('./bar.scss');
document.addEventListener('DOMContentLoaded', () => {
var i18n = {};
var lang = window.navigator.language;
i18n.appName = chrome.i18n.getMessage('appName');
i18n.close = chrome.i18n.getMessage('close');
i18n.yes = chrome.i18n.getMessage('yes');
i18n.never = chrome.i18n.getMessage('never');
i18n.notificationAddSave = chrome.i18n.getMessage('notificationAddSave');
i18n.notificationNeverSave = chrome.i18n.getMessage('notificationNeverSave');
i18n.notificationAddDesc = chrome.i18n.getMessage('notificationAddDesc');
i18n.notificationChangeSave = chrome.i18n.getMessage('notificationChangeSave');
i18n.notificationChangeDesc = chrome.i18n.getMessage('notificationChangeDesc');
lang = chrome.i18n.getUILanguage();
if (typeof safari !== 'undefined') {
const responseCommand = 'notificationBarFrameDataResponse';
sendPlatformMessage({
command: 'bgGetDataForTab',
responseCommand: responseCommand
});
safari.self.addEventListener('message', (msgEvent) => {
const msg = JSON.parse(msgEvent.message.msg);
if (msg.command === responseCommand && msg.data) {
i18n = msg.data.i18n;
load();
}
}, false);
} else {
i18n.appName = chrome.i18n.getMessage('appName');
i18n.close = chrome.i18n.getMessage('close');
i18n.yes = chrome.i18n.getMessage('yes');
i18n.never = chrome.i18n.getMessage('never');
i18n.notificationAddSave = chrome.i18n.getMessage('notificationAddSave');
i18n.notificationNeverSave = chrome.i18n.getMessage('notificationNeverSave');
i18n.notificationAddDesc = chrome.i18n.getMessage('notificationAddDesc');
i18n.notificationChangeSave = chrome.i18n.getMessage('notificationChangeSave');
i18n.notificationChangeDesc = chrome.i18n.getMessage('notificationChangeDesc');
lang = chrome.i18n.getUILanguage();
// delay 50ms so that we get proper body dimensions
setTimeout(load, 50);
// delay 50ms so that we get proper body dimensions
setTimeout(load, 50);
}
function load() {
var closeButton = document.getElementById('close-button'),
@@ -118,6 +131,10 @@ document.addEventListener('DOMContentLoaded', () => {
}
function sendPlatformMessage(msg) {
chrome.runtime.sendMessage(msg);
if (typeof safari !== 'undefined') {
safari.extension.dispatchMessage('bitwarden', msg);
} else {
chrome.runtime.sendMessage(msg);
}
}
});