get data for tab
This commit is contained in:
parent
0229ef328a
commit
ce4e8a9fae
|
@ -84,9 +84,8 @@ export default class RuntimeBackground {
|
|||
setTimeout(async () => await this.main.refreshBadgeAndMenu(), 2000);
|
||||
}
|
||||
break;
|
||||
case 'bgGetAutofillOnPageLoadEnabled':
|
||||
await this.sendStorageValueToTab(ConstantsService.enableAutoFillOnPageLoadKey, sender.tab,
|
||||
msg.responseCommand);
|
||||
case 'bgGetDataForTab':
|
||||
await this.getDataForTab(sender.tab, msg.responseCommand);
|
||||
break;
|
||||
case 'bgOpenNotificationBar':
|
||||
await BrowserApi.tabSendMessageData(sender.tab, 'openNotificationBar', msg.data);
|
||||
|
@ -265,4 +264,18 @@ export default class RuntimeBackground {
|
|||
const val = await this.storageService.get<any>(storageKey);
|
||||
await BrowserApi.tabSendMessageData(tab, responseCommand, val);
|
||||
}
|
||||
|
||||
private async getDataForTab(tab: any, responseCommand: string) {
|
||||
const responseVal: any = {};
|
||||
if (responseCommand === 'notificationBarDataResponse') {
|
||||
responseVal.neverDomains = await this.storageService.get<string[]>(ConstantsService.neverDomainsKey);
|
||||
responseVal.disableAddLoginNotification = await this.storageService.get<boolean>(
|
||||
ConstantsService.disableAddLoginNotificationKey);
|
||||
} else if (responseCommand === 'autofillerAutofillOnPageLoadEnabledResponse') {
|
||||
responseVal.enableAutoFillOnPageLoadKey = await this.storageService.get<boolean>(
|
||||
ConstantsService.enableAutoFillOnPageLoadKey);
|
||||
}
|
||||
|
||||
await BrowserApi.tabSendMessageData(tab, responseCommand, responseVal);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||
if ((typeof safari !== 'undefined')) {
|
||||
const responseCommand = 'autofillerAutofillOnPageLoadEnabledResponse';
|
||||
safari.self.tab.dispatchMessage('bitwarden', {
|
||||
command: 'bgGetAutofillOnPageLoadEnabled',
|
||||
command: 'bgGetDataForTab',
|
||||
responseCommand: responseCommand
|
||||
});
|
||||
safari.self.addEventListener('message', function (msgEvent) {
|
||||
const msg = msgEvent.message;
|
||||
if (msg.command === responseCommand && msg.data === true) {
|
||||
if (msg.command === responseCommand && msg.data[enabledKey] === true) {
|
||||
setInterval(doFillIfNeeded, 500);
|
||||
}
|
||||
}, false);
|
||||
|
|
|
@ -19,7 +19,7 @@ document.addEventListener('DOMContentLoaded', function (event) {
|
|||
if (isSafariApi) {
|
||||
const responseCommand = 'notificationBarDataResponse';
|
||||
safari.self.tab.dispatchMessage('bitwarden', {
|
||||
command: 'bgGetNotificationBarData',
|
||||
command: 'bgGetDataForTab',
|
||||
responseCommand: responseCommand
|
||||
});
|
||||
safari.self.addEventListener('message', function (msgEvent) {
|
||||
|
|
Loading…
Reference in New Issue