Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp, name in *bold* and fix text container location #31

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,21 @@ 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;
}

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
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
}
}

Expand Down