Skip to content

Commit

Permalink
Merge pull request #9 from sarsey-walker/main
Browse files Browse the repository at this point in the history
fix: Able to recognize x on actions
  • Loading branch information
eddieoz authored May 17, 2024
2 parents c616f15 + 52ed34a commit e15130c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
12 changes: 12 additions & 0 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ const siteActions = {
type: 'decrypt', action: () => document.querySelectorAll('body, body *'),
},
],
x: [
{ type: 'sender', action: findUsernameFromInitialState },
{ type: 'userid', action: findTwitterHandle },
{ type: 'senderButton', action: ()=> document.querySelector('[data-testid="dmComposerSendButton"]') },
{
type: 'input', action: () =>
document.querySelector('[data-testid="dmComposerTextInput"]'),
},
{
type: 'decrypt', action: () => document.querySelectorAll('body, body *'),
},
],
whatsapp: [
{ type: 'sender', action: findWhatsappNumberSender },
{ type: 'userid', action: findWhatsappNumber },
Expand Down
19 changes: 9 additions & 10 deletions src/content.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@



// Retrieve the session passphrase securely
async function getSessionPassphrase() {
if (!sessionPassphrase) {
return '[Decryption Failed - No Passphrase]';
}
return sessionPassphrase;
}

// Retrieve private key of the extension user from storage
async function retrieveExtensionUserPrivateKey() {
const extensionUserHandle = globalThis.getAction('sender');
Expand Down Expand Up @@ -326,6 +317,14 @@ async function handleEncryptAndSend() {
const extensionUserHandle = globalThis.getAction('sender');

try {
if(!userHandle){
alert('Failed to encrypt text. Was not possible to get receiver info.');
return null;
}
if(!extensionUserHandle){
alert('Failed to encrypt text. Was not possible to get your user info.');
return null;
}
const recipientPublicKey = await retrieveUserPublicKey(userHandle);
const extensionUserPublicKey = await retrieveUserPublicKeyFromPrivate(extensionUserHandle);

Expand All @@ -347,7 +346,7 @@ async function handleEncryptAndSend() {

// Optionally, click the original send button
// const sendButton = document.querySelector('[data-testid="dmComposerSendButton"]');
// if (sendButton) sendButton.click();
// if (sendButton) sendButton.click();
} catch (err) {
console.error('Failed to encrypt text:', err);
alert('Failed to encrypt text.');
Expand Down

0 comments on commit e15130c

Please sign in to comment.