Skip to content

Commit

Permalink
Merge pull request #37 from XCF-Babble/picker_select_bug
Browse files Browse the repository at this point in the history
Fix bug when selecting picker with decrypted text
  • Loading branch information
yvbbrjdr authored Sep 14, 2019
2 parents 8e2fcfb + b559bec commit 7bc7b83
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/content/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ import { load } from './loader';
window.onload = (): void => {
var cryptFrame: HTMLIFrameElement | null;

const deletePickerIFrame = (): void => {
if (picker) {
picker.deactivate();
}
if (cryptFrame) {
document.documentElement.removeChild(cryptFrame);
cryptFrame = null; // ensure we don't keep the node in mem
}
};

const picker = new ElementPicker(
(selected: Element) => {
walkDOM(
Expand Down Expand Up @@ -104,6 +114,7 @@ window.onload = (): void => {
case 'decryptionPicker':
switch (request.request) {
case 'activateElementPicker':
deletePickerIFrame();
cryptFrame = document.createElement('iframe');
cryptFrame.src = chrome.runtime.getURL('dist/html/decrypt.html');
const pickerCSSStyle: string = [
Expand Down Expand Up @@ -137,13 +148,7 @@ window.onload = (): void => {
sendResponse({ success: true });
break;
case 'deletePickerIFrame':
if (picker) {
picker.deactivate();
}
if (cryptFrame) {
document.documentElement.removeChild(cryptFrame);
cryptFrame = null; // ensure we don't keep the node in mem
}
deletePickerIFrame();
sendResponse({ success: true });
break;
default:
Expand Down

0 comments on commit 7bc7b83

Please sign in to comment.