1
0
mirror of https://github.com/chylex/Discord-History-Tracker.git synced 2024-10-19 05:42:50 +02:00

Compare commits

..

2 Commits

Author SHA1 Message Date
5277f28318
Release v.31h 2024-03-03 14:16:57 +01:00
will-ca
515825f7a4 Update message timestamp processing for latest Discord update (Backport 9030a2f) 2024-03-03 14:15:38 +01:00
5 changed files with 30 additions and 10 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name Discord History Tracker // @name Discord History Tracker
// @version v.31g // @version v.31h
// @license MIT // @license MIT
// @namespace https://chylex.com // @namespace https://chylex.com
// @homepageURL https://dht.chylex.com/ // @homepageURL https://dht.chylex.com/
@ -729,7 +729,7 @@ ${radio("asm", "pause", "Pause Tracking")}
${radio("asm", "switch", "Switch to Next Channel")} ${radio("asm", "switch", "Switch to Next Channel")}
<p id='dht-cfg-note'> <p id='dht-cfg-note'>
It is recommended to disable link and image previews to avoid putting unnecessary strain on your browser.<br><br> It is recommended to disable link and image previews to avoid putting unnecessary strain on your browser.<br><br>
<sub>v.31g, released 25 December 2023</sub> <sub>v.31h, released 03 March 2024</sub>
</p>`); </p>`);
// elements // elements
@ -900,6 +900,16 @@ class SAVEFILE{
return parsedObj && typeof parsedObj.meta === "object" && typeof parsedObj.data === "object"; return parsedObj && typeof parsedObj.meta === "object" && typeof parsedObj.data === "object";
} }
static getDate(date){
if (date instanceof Date) {
return date;
}
else {
// noinspection JSUnresolvedReference
return date.toDate();
}
};
findOrRegisterUser(userId, userName, userDiscriminator, userAvatar){ findOrRegisterUser(userId, userName, userDiscriminator, userAvatar){
var wasPresent = userId in this.meta.users; var wasPresent = userId in this.meta.users;
var userObj = wasPresent ? this.meta.users[userId] : {}; var userObj = wasPresent ? this.meta.users[userId] : {};
@ -989,7 +999,7 @@ class SAVEFILE{
var obj = { var obj = {
u: this.findOrRegisterUser(author.id, author.username, author.bot ? null : author.discriminator, author.avatar), u: this.findOrRegisterUser(author.id, author.username, author.bot ? null : author.discriminator, author.avatar),
t: discordMessage.timestamp.toDate().getTime() t: SAVEFILE.getDate(discordMessage.timestamp).getTime()
}; };
if (discordMessage.content.length > 0){ if (discordMessage.content.length > 0){
@ -997,7 +1007,7 @@ class SAVEFILE{
} }
if (discordMessage.editedTimestamp !== null){ if (discordMessage.editedTimestamp !== null){
obj.te = discordMessage.editedTimestamp.toDate().getTime(); obj.te = SAVEFILE.getDate(discordMessage.editedTimestamp).getTime();
} }
if (discordMessage.embeds.length > 0){ if (discordMessage.embeds.length > 0){

File diff suppressed because one or more lines are too long

View File

@ -8,8 +8,8 @@ import os
import re import re
import distutils.dir_util import distutils.dir_util
VERSION_SHORT = "v.31g" VERSION_SHORT = "v.31h"
VERSION_FULL = VERSION_SHORT + ", released 25 December 2023" VERSION_FULL = VERSION_SHORT + ", released 03 March 2024"
EXEC_UGLIFYJS_WIN = "{2}/lib/uglifyjs.cmd --parse bare_returns --compress --output \"{1}\" \"{0}\"" EXEC_UGLIFYJS_WIN = "{2}/lib/uglifyjs.cmd --parse bare_returns --compress --output \"{1}\" \"{0}\""
EXEC_UGLIFYJS_AUTO = "uglifyjs --parse bare_returns --compress --output \"{1}\" \"{0}\"" EXEC_UGLIFYJS_AUTO = "uglifyjs --parse bare_returns --compress --output \"{1}\" \"{0}\""

View File

@ -114,6 +114,16 @@ class SAVEFILE{
return parsedObj && typeof parsedObj.meta === "object" && typeof parsedObj.data === "object"; return parsedObj && typeof parsedObj.meta === "object" && typeof parsedObj.data === "object";
} }
static getDate(date){
if (date instanceof Date) {
return date;
}
else {
// noinspection JSUnresolvedReference
return date.toDate();
}
};
findOrRegisterUser(userId, userName, userDiscriminator, userAvatar){ findOrRegisterUser(userId, userName, userDiscriminator, userAvatar){
var wasPresent = userId in this.meta.users; var wasPresent = userId in this.meta.users;
var userObj = wasPresent ? this.meta.users[userId] : {}; var userObj = wasPresent ? this.meta.users[userId] : {};
@ -203,7 +213,7 @@ class SAVEFILE{
var obj = { var obj = {
u: this.findOrRegisterUser(author.id, author.username, author.bot ? null : author.discriminator, author.avatar), u: this.findOrRegisterUser(author.id, author.username, author.bot ? null : author.discriminator, author.avatar),
t: discordMessage.timestamp.toDate().getTime() t: SAVEFILE.getDate(discordMessage.timestamp).getTime()
}; };
if (discordMessage.content.length > 0){ if (discordMessage.content.length > 0){
@ -211,7 +221,7 @@ class SAVEFILE{
} }
if (discordMessage.editedTimestamp !== null){ if (discordMessage.editedTimestamp !== null){
obj.te = discordMessage.editedTimestamp.toDate().getTime(); obj.te = SAVEFILE.getDate(discordMessage.editedTimestamp).getTime();
} }
if (discordMessage.embeds.length > 0){ if (discordMessage.embeds.length > 0){