-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from vivek-nexus/v1.1.0
v1.1.0
- Loading branch information
Showing
4 changed files
with
155 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,67 @@ | ||
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { | ||
console.log(request.transcript) | ||
chrome.storage.local.set({ transcript: request.transcript }, function () { | ||
console.log("Saved transcript") | ||
}) | ||
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) { | ||
console.log(message.type) | ||
if (message.type == "save_and_download") { | ||
chrome.storage.local.set( | ||
{ | ||
transcript: message.transcript, | ||
meetingTitle: message.meetingTitle, | ||
meetingStartTimeStamp: message.meetingStartTimeStamp | ||
}, | ||
function () { | ||
console.log("Saved transcript and meta data, downloading now if non empty") | ||
if (message.transcript.length > 0) | ||
downloadTranscript() | ||
}) | ||
} | ||
if (message.type == "download") { | ||
downloadTranscript() | ||
} | ||
return true | ||
}) | ||
}) | ||
|
||
function downloadTranscript() { | ||
chrome.storage.local.get(["transcript", "meetingTitle", "meetingStartTimeStamp"], function (result) { | ||
if (result.transcript) { | ||
const fileName = result.meetingTitle && result.meetingStartTimeStamp ? `Transcripto/Transcript-${result.meetingTitle} at ${result.meetingStartTimeStamp}.txt` : `Transcripto/Transcript.txt` | ||
|
||
// Create an array to store lines of the text file | ||
const lines = []; | ||
|
||
// Iterate through the transcript array and format each entry | ||
result.transcript.forEach(entry => { | ||
lines.push(entry.personName); | ||
lines.push(entry.personTranscript); | ||
lines.push(''); // Add an empty line between entries | ||
}); | ||
|
||
lines.push("---") | ||
lines.push("Transcript saved using Transcripto Chrome extension") | ||
|
||
// Join the lines into a single string | ||
const textContent = lines.join('\n'); | ||
|
||
// Create a Blob from the text content | ||
const blob = new Blob([textContent], { type: 'text/plain' }); | ||
|
||
// Create a download | ||
// Use Chrome Download API | ||
chrome.downloads.download({ | ||
url: 'data:text/plain;base64,' + btoa(textContent), | ||
filename: fileName, | ||
conflictAction: 'uniquify' // Automatically rename the file if it already exists | ||
}).then(() => { | ||
console.log("Transcript downloaded to Transcripto directory") | ||
}).catch((error) => { | ||
console.log(error) | ||
chrome.downloads.download({ | ||
url: 'data:text/plain;base64,' + btoa(textContent), | ||
filename: "Transcripto/Transcript.txt", | ||
conflictAction: 'uniquify' // Automatically rename the file if it already exists | ||
}) | ||
console.log("Invalid file name. Transcript downloaded to Transcripto directory with simple file name.") | ||
}) | ||
} | ||
else | ||
console.log("No transcript found") | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters