From f3a3dbce5a9e09a008e6010dcd37b9492c139758 Mon Sep 17 00:00:00 2001 From: Federico Gimenez Molinelli Date: Fri, 24 Feb 2023 18:40:32 -0300 Subject: [PATCH 1/3] Updated to manifest v3 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 4e517ce..73d8497 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { -"manifest_version": 2, +"manifest_version": 3, "name": "Google Chat thread links & quote reply", "description": "Adds button to copy links to threads on Google Chat and adds button to messages to quote reply", "version": "0.0.12", From e00d620a7c65123d160db0d98ae34f4d2e2af887 Mon Sep 17 00:00:00 2001 From: Federico Gimenez Molinelli Date: Fri, 24 Feb 2023 18:41:10 -0300 Subject: [PATCH 2/3] Add name in *bold* and a timestamp with timezone --- content.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/content.js b/content.js index ec673bb..d3d666b 100644 --- a/content.js +++ b/content.js @@ -230,9 +230,16 @@ function main() { if (elRef.parentElement.children[messageIndex].className.includes('AnmYv')) { const nameContainer = elRef.parentElement.children[messageIndex].querySelector('[data-hovercard-id], [data-member-id]'); name = nameContainer.getAttribute('data-name'); + timeStamp = elRef.parentElement.children[messageIndex].querySelector('span[data-absolute-timestamp]').getAttribute('data-absolute-timestamp'); + const df = new Date(parseInt(timeStamp)); + time = df.getFullYear()+"-"+ + String((df.getMonth()+1)).padStart(2,'0')+"-"+ + String(df.getDate()).padStart(2,'0')+" "+ + String(df.getHours()).padStart(2,'0')+":"+ + String(df.getMinutes()).padStart(2,'0')+":"+ + String(df.getSeconds()).padStart(2,'0')+" "+ + "UTC-"+(String(Math.floor(df.getTimezoneOffset()/60)).padStart(2,'0'))+":"+String(df.getTimezoneOffset()%60).padStart(2,'0') break; - // Can extract time, but adding it into static text surrounded by relative time that's rendered in the chats will only confuse people - // time = el.Ref.parentElement.children[messageIndex].querySelector('span[data-absolute-timestamp]').getAttribute('data-absolute-timestamp'); } messageIndex -= 1; } @@ -247,7 +254,7 @@ function main() { return; } - inputEl.innerHTML = makeInputText(name, quoteText, inputEl, messageContainer); + inputEl.innerHTML = makeInputText(name, time, quoteText, inputEl, messageContainer); inputEl.scrollIntoView(); inputEl.click(); placeCaretAtEnd(inputEl); @@ -263,7 +270,7 @@ function main() { } } -function makeInputText(name, quoteText, inputEl, messageContainer) { +function makeInputText(name, time, quoteText, inputEl, messageContainer) { var isDM = window.location.href.includes('/dm/'); var selection = window.getSelection().toString(); var text = getText(messageContainer); @@ -284,12 +291,11 @@ function makeInputText(name, quoteText, inputEl, messageContainer) { } if(isDM) { - return oneLineQuote ? '`' + oneLineQuote + '`\n' : - ("```\n" + quoteText + "\n```\n" + inputEl.innerHTML) + return oneLineQuote ? "(`" + time + "`): " + '`' + oneLineQuote + '`\n' : + ("(`" + time + "`): " + "```\n" + quoteText + "\n```\n" + inputEl.innerHTML) } else { - - return oneLineQuote ? '`' + name + ': ' + oneLineQuote + '`\n' : - ("```\n" + name + ":\n" + quoteText + "\n```\n" + inputEl.innerHTML); + return oneLineQuote ? "*" + name + "*" + " (`" + time + "`): " + '`' + oneLineQuote + '`\n' : + ("*" + name + "*" + " (`" + time + "`): " + "```\n" + quoteText + "\n```\n" + inputEl.innerHTML); } } From d3d650684d2e1629237d03d3380c2f8afd614ef5 Mon Sep 17 00:00:00 2001 From: Federico Gimenez Molinelli Date: Fri, 27 Oct 2023 14:05:47 -0300 Subject: [PATCH 3/3] Fix messageContainer location --- content.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content.js b/content.js index b8745bb..75fa392 100644 --- a/content.js +++ b/content.js @@ -244,7 +244,7 @@ function main() { messageIndex -= 1; } - var messageContainer = addreactionButton.parentElement.parentElement.parentElement.parentElement.children[0]; + var messageContainer = addreactionButton.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children[0]; var quoteText = getQuoteText(messageContainer); let inputEl = e.querySelector('div[contenteditable="true"]'); // This fetches the input element in channels