mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Merge pull request #1822 from keepassxreboot/fix/remove_getbackgroundpage
Remove browser.runtime.getBackgroundPage()
This commit is contained in:
commit
6e6c305da9
5 changed files with 25 additions and 11 deletions
|
|
@ -234,6 +234,7 @@ kpxcEvent.messageHandlers = {
|
|||
'get_database_hash': keepass.getDatabaseHash,
|
||||
'get_database_groups': keepass.getDatabaseGroups,
|
||||
'get_keepassxc_versions': kpxcEvent.onGetKeePassXCVersions,
|
||||
'get_login_list': page.getLoginList,
|
||||
'get_status': kpxcEvent.onGetStatus,
|
||||
'get_tab_information': kpxcEvent.onGetTabInformation,
|
||||
'get_totp': keepass.getTotp,
|
||||
|
|
|
|||
|
|
@ -371,6 +371,14 @@ page.setAutoSubmitPerformed = async function(tab) {
|
|||
}
|
||||
};
|
||||
|
||||
page.getLoginList = async function(tab) {
|
||||
if (page.tabs[tab.id]) {
|
||||
return page.tabs[tab.id].loginList;
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
// Update context menu for attribute filling
|
||||
page.updateContextMenu = async function(tab, credentials) {
|
||||
// Remove any old attribute items
|
||||
|
|
|
|||
|
|
@ -48,6 +48,19 @@ async function initColorTheme() {
|
|||
}
|
||||
}
|
||||
|
||||
async function getLoginData() {
|
||||
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
|
||||
if (tabs.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const logins = await browser.runtime.sendMessage({
|
||||
action: 'get_login_list'
|
||||
});
|
||||
|
||||
return logins;
|
||||
}
|
||||
|
||||
// Sets default popup size for Chromium based browsers to prevent flash on popup open
|
||||
function setDefaultPopupSize() {
|
||||
if (!isFirefox()) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
const getLoginData = async () => {
|
||||
const global = await browser.runtime.getBackgroundPage();
|
||||
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
|
||||
return global.page.tabs[tabs[0].id].loginList;
|
||||
};
|
||||
|
||||
(async () => {
|
||||
resizePopup();
|
||||
await initColorTheme();
|
||||
|
|
|
|||
|
|
@ -6,14 +6,12 @@
|
|||
|
||||
$('#lock-database-button').show();
|
||||
|
||||
const global = await browser.runtime.getBackgroundPage();
|
||||
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
|
||||
if (tabs.length === 0) {
|
||||
return; // For example: only the background devtools or a popup are opened
|
||||
return [];
|
||||
}
|
||||
|
||||
const tab = tabs[0];
|
||||
const logins = global.page.tabs[tab.id].loginList;
|
||||
const logins = await getLoginData();
|
||||
const ll = document.getElementById('login-list');
|
||||
|
||||
for (let i = 0; i < logins.length; i++) {
|
||||
|
|
@ -29,7 +27,7 @@
|
|||
}
|
||||
|
||||
const id = e.target.id;
|
||||
browser.tabs.sendMessage(tab.id, {
|
||||
browser.tabs.sendMessage(tabs[0].id, {
|
||||
action: 'fill_user_pass_with_specific_login',
|
||||
id: Number(id),
|
||||
uuid: uuid
|
||||
|
|
|
|||
Loading…
Reference in a new issue