#1515 Clipboard WIP

This commit is contained in:
GrzegorzZajac000 2024-03-18 18:38:25 +01:00
parent 9bcb9baf1c
commit 794ffcfc77
8 changed files with 10 additions and 30 deletions

View File

@ -111,7 +111,6 @@
},
"dependencies": {
"@babel/runtime": "^7.24.0",
"@extend-chrome/clipboard": "^2.0.0",
"qrcode": "^1.5.3",
"uuid": "^9.0.0"
}

View File

@ -17,12 +17,10 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>
//
const browser = require('webextension-polyfill');
const config = require('../../config');
const loadFromLocalStorage = require('../../localStorage/loadFromLocalStorage');
const { notification, inputToken, getTokenInput, showNotificationInfo, loadFonts, isInFrame, pageLoadComplete } = require('../functions');
const storeLog = require('../../partials/storeLog');
const { clipboard } = require('@extend-chrome/clipboard');
const contentOnMessage = async (request, tabData) => {
if (!request || !request.action) {
@ -56,27 +54,14 @@ const contentOnMessage = async (request, tabData) => {
if (lastFocusedInput) {
tokenInput = getTokenInput(lastFocusedInput);
}
if (!lastFocusedInput || !tokenInput) {
// Show token in notification
return; // @TODO: remove
} else {
return clipboard.writeText(request.token)
.then(() => browser.runtime.sendMessage({
action: 'notificationOnBackground',
data: config.Texts.Info.CopiedToClipboard,
tabID: tabData?.id
}))
.then(() => {
return { status: 'clipboard' };
})
.catch(err => {
console.error(err);
// @TODO: catch err
});
return inputToken(request, tokenInput, tabData?.url);
}
if (!tokenInput) {
return { status: 'elementNotFound' };
}
return inputToken(request, tokenInput, tabData?.url);
}
case 'pageLoadComplete': {

View File

@ -33,6 +33,7 @@
top: 25px !important;
user-select: none !important;
z-index: 999999 !important;
z-index: infinite !important;
@media all and (max-width: 400px) {
padding: 10px !important;

View File

@ -71,8 +71,7 @@
"tabs",
"storage",
"notifications",
"contextMenus",
"clipboardWrite"
"contextMenus"
],
"host_permissions": [
"*://*.2fas.com/*"

View File

@ -71,8 +71,7 @@
"tabs",
"storage",
"notifications",
"contextMenus",
"clipboardWrite"
"contextMenus"
],
"host_permissions": [
"*://*.2fas.com/*"

View File

@ -77,7 +77,6 @@
"storage",
"notifications",
"contextMenus",
"clipboardWrite",
"https://*.2fas.com/*",
"wss://*.2fas.com/*"
],

View File

@ -70,8 +70,7 @@
"tabs",
"storage",
"notifications",
"contextMenus",
"clipboardWrite"
"contextMenus"
],
"host_permissions": [
"*://*.2fas.com/*"

View File

@ -77,7 +77,6 @@
"storage",
"notifications",
"contextMenus",
"clipboardWrite",
"https://*.2fas.com/*",
"wss://*.2fas.com/*"
],