Skip to content

Commit d3936e0

Browse files
committed
Fix chat messages and improve error handling
1 parent 04185f9 commit d3936e0

4 files changed

Lines changed: 21 additions & 20 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Simple Google Meet transcripts. Private and open source.
33

44
![marquee-large](/assets/marquee-large.png)
55

6-
Extension status: 🟢 OPERATIONAL (v2.3.0)
6+
Extension status: 🟢 OPERATIONAL (v2.3.1)
77

88
<br />
99
<br />

extension/background.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,24 @@ chrome.tabs.onRemoved.addListener(function (tabid) {
3535

3636
function downloadTranscript() {
3737
chrome.storage.local.get(["userName", "transcript", "chatMessages", "meetingTitle", "meetingStartTimeStamp"], function (result) {
38-
if (result.userName && result.transcript && result.chatMessages) {
38+
if (result.userName && (result.transcript.length > 0 || result.chatMessages.length > 0)) {
3939
// Create file name if values or provided, use default otherwise
4040
const fileName = result.meetingTitle && result.meetingStartTimeStamp ? `TranscripTonic/Transcript-${result.meetingTitle} at ${result.meetingStartTimeStamp}.txt` : `TranscripTonic/Transcript.txt`
4141

4242
// Create an array to store lines of the text file
4343
const lines = []
4444

45-
// Iterate through the transcript array and format each entry
46-
result.transcript.forEach(entry => {
47-
lines.push(`${entry.personName} (${entry.timeStamp})`)
48-
lines.push(entry.personTranscript)
49-
// Add an empty line between entries
45+
if (result.transcript.length > 0) {
46+
// Iterate through the transcript array and format each entry
47+
result.transcript.forEach(entry => {
48+
lines.push(`${entry.personName} (${entry.timeStamp})`)
49+
lines.push(entry.personTranscript)
50+
// Add an empty line between entries
51+
lines.push("")
52+
})
5053
lines.push("")
51-
})
52-
lines.push("")
53-
lines.push("")
54+
lines.push("")
55+
}
5456

5557
if (result.chatMessages.length > 0) {
5658
// Iterate through the chat messages array and format each entry

extension/content.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ overWriteChromeStorage(["userName"], false)
2020
// Transcript array that holds one or more transcript blocks
2121
// Each transcript block (object) has personName, timeStamp and transcriptText key value pairs
2222
let transcript = []
23+
overWriteChromeStorage(["transcript"], false)
2324
// Buffer variables to dump values, which get pushed to transcript array as transcript blocks, at defined conditions
2425
let personNameBuffer = "", transcriptTextBuffer = "", timeStampBuffer = undefined
2526
// Buffer variables for deciding when to push a transcript block
@@ -162,7 +163,7 @@ function meetingRoutines(uiType) {
162163
const transcriptTargetNode = document.querySelector('.a4cQT')
163164
// Attempt to dim down the transcript
164165
try {
165-
transcriptTargetNode.childNodes[1].style.opacity = 0.2
166+
transcriptTargetNode.childNodes[1].setAttribute("style", "opacity:0.2")
166167
} catch (error) {
167168
console.error(error)
168169
}
@@ -183,7 +184,7 @@ function meetingRoutines(uiType) {
183184
chatMessagesButton.click()
184185
// CRITICAL DOM DEPENDENCY. Grab the chat messages element. This element is present, irrespective of chat ON/OFF, once it appears for this first time.
185186
try {
186-
const chatMessagesTargetNode = document.querySelectorAll('div[aria-live="polite"]')[0]
187+
const chatMessagesTargetNode = document.querySelector('div[aria-live="polite"].Ge9Kpc')
187188

188189
// Create chat messages observer instance linked to the callback function. Registered irrespective of operation mode.
189190
chatMessagesObserver = new MutationObserver(chatMessagesRecorder)
@@ -193,7 +194,7 @@ function meetingRoutines(uiType) {
193194
console.error(error)
194195
showNotification(extensionStatusJSON_bug)
195196
}
196-
}, 500)
197+
}, 1000)
197198

198199
// Show confirmation message from extensionStatusJSON, once observation has started, based on operation mode
199200
chrome.storage.sync.get(["operationMode"], function (result) {
@@ -389,7 +390,7 @@ function chatMessagesRecorder(mutationsList, observer) {
389390
mutationsList.forEach(mutation => {
390391
try {
391392
// CRITICAL DOM DEPENDENCY. Get all people in the transcript
392-
const chatMessagesElement = document.querySelectorAll('div[aria-live="polite"]')[0]
393+
const chatMessagesElement = document.querySelector('div[aria-live="polite"].Ge9Kpc')
393394
// Attempt to parse messages only if at least one message exists
394395
if (chatMessagesElement.children.length > 0) {
395396
// CRITICAL DOM DEPENDENCY. Get the last message that was sent/received.
@@ -461,11 +462,9 @@ function overWriteChromeStorage(keys, sendDownloadMessage) {
461462
chrome.storage.local.set(objectToSave, function () {
462463
if (sendDownloadMessage) {
463464
// Download only if any transcript is present, irrespective of chat messages
464-
if (transcript.length > 0) {
465-
chrome.runtime.sendMessage({ type: "download" }, function (response) {
466-
console.log(response);
467-
})
468-
}
465+
chrome.runtime.sendMessage({ type: "download" }, function (response) {
466+
console.log(response);
467+
})
469468
}
470469
})
471470
}

extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "TranscripTonic",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"manifest_version": 3,
55
"description": "Simple Google Meet transcripts. Private and open source.",
66
"action": {

0 commit comments

Comments
 (0)