Skip to content

Commit

Permalink
updated configuration using local storage
Browse files Browse the repository at this point in the history
Signed-off-by: aryangupta701 <[email protected]>
  • Loading branch information
aryangupta701 committed Jul 29, 2023
1 parent e53dd2f commit c05271e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions source/ContentScript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,20 @@ function enableExtension(): void {
reportPageLoaded(document, reportObject);
}

function configureExtension(): void {
const localzapurl = localStorage.getItem('localzapurl');
const localzapenable = localStorage.getItem('localzapenable') || true;
if (localzapurl) {
Browser.storage.sync.set({
zapurl: localzapurl,
zapenable: localzapenable !== 'false',
});
}
}

function injectScript(): Promise<boolean> {
return new Promise((resolve) => {
const localzapurl = localStorage.getItem('localzapurl');
const localzapenable = localStorage.getItem('localzapenable') || true;
if (localzapurl) {
Browser.storage.sync.set({
zapurl: localzapurl,
zapenable: localzapenable !== 'false',
});
}
configureExtension();
withZapRecordingActive(() => {
recorder.recordUserInteractions();
});
Expand All @@ -250,6 +254,7 @@ injectScript();
Browser.runtime.onMessage.addListener(
(message: MessageEvent, _sender: Runtime.MessageSender) => {
if (message.type === 'zapStartRecording') {
configureExtension();
recorder.initializationScript();
recorder.recordUserInteractions();
} else if (message.type === 'zapStopRecording') {
Expand Down

0 comments on commit c05271e

Please sign in to comment.