mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2026-10-22 23:12:12 +03:00
Release v.32 (app)
This commit is contained in:
4 files changed
+4
-4
No files matched your search
@@ -12,7 +12,7 @@
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
<AssemblyName>DiscordHistoryTracker</AssemblyName>
|
||||
<Version>31.0.0.0</Version>
|
||||
<Version>32.0.0.0</Version>
|
||||
<AssemblyVersion>$(Version)</AssemblyVersion>
|
||||
<FileVersion>$(Version)</FileVersion>
|
||||
<PackageVersion>$(Version)</PackageVersion>
|
||||
|
||||
@@ -1 +1 @@
|
||||
class DISCORD{static getMessageOuterElement(){return DOM.queryReactClass("messagesWrapper")}static getMessageScrollerElement(){return this.getMessageOuterElement().querySelector("[class*='scroller-']")}static hasMoreMessages(){return document.querySelector("#messagesNavigationDescription + [class^=container]")===null}static loadOlderMessages(){const view=this.getMessageScrollerElement();if(view.scrollTop>0){view.scrollTop=0}}static setupMessageCallback(callback){let skipsLeft=0;let waitForCleanup=false;const previousMessages=new Set;return window.setInterval(()=>{if(skipsLeft>0){--skipsLeft;return}const view=this.getMessageOuterElement();if(!view){skipsLeft=2;return}const anyMessage=this.getMessageOuterElement().querySelector("[class*='message-']");const messageCount=anyMessage?anyMessage.parentElement.children.length:0;if(messageCount>300){if(waitForCleanup){return}skipsLeft=3;waitForCleanup=true;window.setTimeout(()=>{const view=this.getMessageScrollerElement();view.scrollTop=view.scrollHeight/2},1)}else{waitForCleanup=false}const messages=this.getMessages();let hasChanged=false;for(const message of messages){if(!previousMessages.has(message.id)){hasChanged=true;break}}if(!hasChanged){return}previousMessages.clear();for(const message of messages){previousMessages.add(message.id)}callback(messages)},200)}static getSelectedChannel(){try{let obj;let channelListEle=DOM.queryReactClass("privateChannels");if(channelListEle){const channel=DOM.queryReactClass("selected",channelListEle);if(!channel||!("href"in channel)||!channel.href.includes("/@me/")){return null}const linkSplit=channel.href.split("/");const id=linkSplit[linkSplit.length-1];if(!/^\d+$/.test(id)){return null}let name;for(const ele of channel.querySelectorAll("[class^='name-'] *")){const node=Array.prototype.find.call(ele.childNodes,node=>node.nodeType===Node.TEXT_NODE);if(node){name=node.nodeValue;break}}if(!name){return null}const icon=channel.querySelector("img[class*='avatar']");const iconParent=icon&&icon.closest("foreignObject");const iconMask=iconParent&&iconParent.getAttribute("mask");obj={server:{id:id,name:name,type:iconMask&&iconMask.includes("#svg-mask-avatar-default")?"GROUP":"DM"},channel:{id:id,name:name}}}else{channelListEle=document.getElementById("channels");const channel=channelListEle.querySelector("[class*='modeSelected']").parentElement;const props=DOM.getReactProps(channel).children.props;if(!props){return null}const channelObj=props.channel||props.children().props.channel;if(!channelObj){return null}obj={server:{id:channelObj.guild_id,name:document.querySelector("nav header > h1").innerText,type:"SERVER"},channel:{id:channelObj.id,name:channelObj.name,extra:{position:channelObj.position,topic:channelObj.topic,nsfw:channelObj.nsfw}}}}return obj.channel.length===0?null:obj}catch(e){console.error(e);return null}}static getMessages(){try{const scroller=this.getMessageScrollerElement();const props=DOM.getReactProps(scroller);let wrappers;try{wrappers=props.children.props.children.props.children.props.children.find(ele=>Array.isArray(ele))}catch(e){wrappers=props.children.find(ele=>Array.isArray(ele))}const messages=[];for(const obj of wrappers){const nested=obj.props;if(nested&&nested.message){messages.push(nested.message)}}return messages}catch(e){console.error(e);return null}}static selectNextTextChannel(){const dms=DOM.queryReactClass("privateChannels");if(dms){const currentChannel=DOM.queryReactClass("selected",dms);const nextChannel=currentChannel&¤tChannel.nextElementSibling;if(!nextChannel||!nextChannel.getAttribute("class").includes("channel-")||!("href"in nextChannel)||!nextChannel.href.includes("/@me/")){return false}else{nextChannel.click();nextChannel.scrollIntoView(true);return true}}else{const channelIconNormal="M5.88657 21C5.57547 21 5.3399 20.7189 5.39427 20.4126L6.00001 17H2.59511C2.28449 17 2.04905 16.7198 2.10259 16.4138L2.27759 15.4138C2.31946 15.1746 2.52722 15 2.77011 15H6.35001L7.41001 9H4.00511C3.69449 9 3.45905 8.71977 3.51259 8.41381L3.68759 7.41381C3.72946 7.17456 3.93722 7 4.18011 7H7.76001L8.39677 3.41262C8.43914 3.17391 8.64664 3 8.88907 3H9.87344C10.1845 3 10.4201 3.28107 10.3657 3.58738L9.76001 7H15.76L16.3968 3.41262C16.4391 3.17391 16.6466 3 16.8891 3H17.8734C18.1845 3 18.4201 3.28107 18.3657 3.58738L17.76 7H21.1649C21.4755 7 21.711 7.28023 21.6574 7.58619L21.4824 8.58619C21.4406 8.82544 21.2328 9 20.9899 9H17.41L16.35 15H19.7549C20.0655 15 20.301 15.2802 20.2474 15.5862L20.0724 16.5862C20.0306 16.8254 19.8228 17 19.5799 17H16L15.3632 20.5874C15.3209 20.8261 15.1134 21 14.8709 21H13.8866C13.5755 21 13.3399 20.7189 13.3943 20.4126L14 17H8.00001L7.36325 20.5874C7.32088 20.8261 7.11337 21 6.87094 21H5.88657ZM9.41045 9L8.35045 15H14.3504L15.4104 9H9.41045Z";const channelIconSpecial="M14 8C14 7.44772 13.5523 7 13 7H9.76001L10.3657 3.58738C10.4201 3.28107 10.1845 3 9.87344 3H8.88907C8.64664 3 8.43914 3.17391 8.39677 3.41262L7.76001 7H4.18011C3.93722 7 3.72946 7.17456 3.68759 7.41381L3.51259 8.41Line truncated
|
||||
class DISCORD{static getMessageOuterElement(){return DOM.queryReactClass("messagesWrapper")}static getMessageScrollerElement(){return DOM.queryReactClass("scroller",this.getMessageOuterElement())}static getMessageElements(){return this.getMessageOuterElement().querySelectorAll("[class*='message-']")}static hasMoreMessages(){return document.querySelector("#messagesNavigationDescription + [class^=container]")===null}static loadOlderMessages(){const view=this.getMessageScrollerElement();if(view.scrollTop>0){view.scrollTop=0}}static setupMessageCallback(callback){let skipsLeft=0;let waitForCleanup=false;const previousMessages=new Set;return window.setInterval(()=>{if(skipsLeft>0){--skipsLeft;return}const view=this.getMessageOuterElement();if(!view){skipsLeft=2;return}const anyMessage=DOM.queryReactClass("message",this.getMessageOuterElement());const messageCount=anyMessage?anyMessage.parentElement.children.length:0;if(messageCount>300){if(waitForCleanup){return}skipsLeft=3;waitForCleanup=true;window.setTimeout(()=>{const view=this.getMessageScrollerElement();view.scrollTop=view.scrollHeight/2},1)}else{waitForCleanup=false}const messages=this.getMessages();let hasChanged=false;for(const message of messages){if(!previousMessages.has(message.id)){hasChanged=true;break}}if(!hasChanged){return}previousMessages.clear();for(const message of messages){previousMessages.add(message.id)}callback(messages)},200)}static getMessageElementProps(ele){const props=DOM.getReactProps(ele);if(props.children&&props.children.length>=4){const childProps=props.children[3].props;if("message"in childProps&&"channel"in childProps){return childProps}}return null}static getMessages(){try{const messages=[];for(const ele of this.getMessageElements()){const props=this.getMessageElementProps(ele);if(props!=null){messages.push(props.message)}}return messages}catch(e){console.error(e);return[]}}static getSelectedChannel(){try{let obj;for(const ele of this.getMessageElements()){const props=this.getMessageElementProps(ele);if(props!=null){obj=props.channel;break}}if(!obj){return null}const dms=DOM.queryReactClass("privateChannels");if(dms){let name;for(const ele of dms.querySelectorAll("[class*='channel-'][class*='selected-'] [class^='name-'] *")){const node=Array.prototype.find.call(ele.childNodes,node=>node.nodeType===Node.TEXT_NODE);if(node){name=node.nodeValue;break}}if(!name){return null}let type;switch(obj.type){case 1:type="DM";break;case 3:type="GROUP";break;default:return null}const id=obj.id;const server={id:id,name:name,type:type};const channel={id:id,name:name};return{server:server,channel:channel}}else if(obj.guild_id){const server={id:obj.guild_id,name:document.querySelector("nav header > h1").innerText,type:"SERVER"};const channel={id:obj.id,name:obj.name,extra:{nsfw:obj.nsfw}};if(obj.parent_id){channel["extra"]["parent"]=obj.parent_id}else{channel["extra"]["position"]=obj.position;channel["extra"]["topic"]=obj.topic}return{server:server,channel:channel}}else{return null}}catch(e){console.error(e);return null}}static selectNextTextChannel(){const dms=DOM.queryReactClass("privateChannels");if(dms){const currentChannel=DOM.queryReactClass("selected",dms);const nextChannel=currentChannel&¤tChannel.nextElementSibling;if(!nextChannel||!nextChannel.getAttribute("class").includes("channel-")||!("href"in nextChannel)||!nextChannel.href.includes("/@me/")){return false}else{nextChannel.click();nextChannel.scrollIntoView(true);return true}}else{const channelIcons=["M5.88657 21C5.57547 21 5.3399 20.7189 5.39427 20.4126L6.00001 17H2.59511C2.28449 17 2.04905 16.7198 2.10259 16.4138L2.27759 15.4138C2.31946 15.1746 2.52722 15 2.77011 15H6.35001L7.41001 9H4.00511C3.69449 9 3.45905 8.71977 3.51259 8.41381L3.68759 7.41381C3.72946 7.17456 3.93722 7 4.18011 7H7.76001L8.39677 3.41262C8.43914 3.17391 8.64664 3 8.88907 3H9.87344C10.1845 3 10.4201 3.28107 10.3657 3.58738L9.76001 7H15.76L16.3968 3.41262C16.4391 3.17391 16.6466 3 16.8891 3H17.8734C18.1845 3 18.4201 3.28107 18.3657 3.58738L17.76 7H21.1649C21.4755 7 21.711 7.28023 21.6574 7.58619L21.4824 8.58619C21.4406 8.82544 21.2328 9 20.9899 9H17.41L16.35 15H19.7549C20.0655 15 20.301 15.2802 20.2474 15.5862L20.0724 16.5862C20.0306 16.8254 19.8228 17 19.5799 17H16L15.3632 20.5874C15.3209 20.8261 15.1134 21 14.8709 21H13.8866C13.5755 21 13.3399 20.7189 13.3943 20.4126L14 17H8.00001L7.36325 20.5874C7.32088 20.8261 7.11337 21 6.87094 21H5.88657ZM9.41045 9L8.35045 15H14.3504L15.4104 9H9.41045Z","M5.43309 21C5.35842 21 5.30189 20.9325 5.31494 20.859L5.99991 17H2.14274C2.06819 17 2.01168 16.9327 2.02453 16.8593L2.33253 15.0993C2.34258 15.0419 2.39244 15 2.45074 15H6.34991L7.40991 9H3.55274C3.47819 9 3.42168 8.93274 3.43453 8.85931L3.74253 7.09931C3.75258 7.04189 3.80244 7 3.86074 7H7.75991L8.45234 3.09903C8.46251 3.04174 8.51231 3 8.57049 3H10.3267C10.4014 3 10.4579 3.06746 10.4449 3.14097L9.75991 7H15.7599L16.4523 3.09903C16.4625 3.04174 16.5123 3 16.5705 3H18.3267C18.4014 3 18.4579 3.06746 18.4449 3.14097LLine truncated
|
||||
@@ -1 +1 @@
|
||||
const STATE=function(){let serverPort=-1;let serverToken="";const post=function(endpoint,json){const aborter=new AbortController;const timeout=window.setTimeout(()=>aborter.abort(),5e3);return new Promise(async(resolve,reject)=>{let r;try{r=await fetch("http://127.0.0.1:"+serverPort+endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-DHT-Token":serverToken},credentials:"omit",redirect:"error",body:JSON.stringify(json),signal:aborter.signal})}catch(e){if(e.name==="AbortError"){reject({status:"DISCONNECTED"});return}else{reject({status:"ERROR",message:e.message});return}}finally{window.clearTimeout(timeout)}if(r.status===200){resolve(r);return}try{const message=await r.text();reject({status:"ERROR",message:message})}catch(e){reject({status:"ERROR",message:e.message})}})};const trackingStateChangedListeners=[];let isTracking=false;const addedChannels=new Set;const addedUsers=new Set;return{setup(port,token){serverPort=port;serverToken=token},onTrackingStateChanged(callback){trackingStateChangedListeners.push(callback);callback(isTracking)},isTracking(){return isTracking},setIsTracking(state){if(isTracking!==state){isTracking=state;if(isTracking){addedChannels.clear();addedUsers.clear()}for(const callback of trackingStateChangedListeners){callback(isTracking)}}},async addDiscordChannel(serverInfo,channelInfo){if(addedChannels.has(channelInfo.id)){return}const server={id:serverInfo.id,name:serverInfo.name,type:serverInfo.type};const channel={id:channelInfo.id,name:channelInfo.name};if("extra"in channelInfo){channel.position=channelInfo.extra.position;channel.topic=channelInfo.extra.topic;channel.nsfw=channelInfo.extra.nsfw}await post("/track-channel",{server:server,channel:channel});addedChannels.add(channelInfo.id)},async addDiscordMessages(channelId,discordMessageArray){const userInfo={};let hasNewUsers=false;for(const msg of discordMessageArray){const user=msg.author;if(!addedUsers.has(user.id)){const obj={id:user.id,name:user.username};if(user.avatar){obj.avatar=user.avatar}if(!user.bot){obj.discriminator=user.discriminator}userInfo[user.id]=obj;hasNewUsers=true}}if(hasNewUsers){await post("/track-users",Object.values(userInfo));for(const id of Object.keys(userInfo)){addedUsers.add(id)}}const response=await post("/track-messages",discordMessageArray.map(msg=>{const obj={id:msg.id,sender:msg.author.id,channel:msg.channel_id,text:msg.content,timestamp:msg.timestamp.toDate().getTime()};if(msg.editedTimestamp!==null){obj.editTimestamp=msg.editedTimestamp.toDate().getTime()}if(msg.messageReference!==null){obj.repliedToId=msg.messageReference.message_id}if(msg.attachments.length>0){obj.attachments=msg.attachments.map(attachment=>{const mapped={id:attachment.id,name:attachment.filename,size:attachment.size,url:attachment.url};if(attachment.content_type){mapped.type=attachment.content_type}return mapped})}if(msg.embeds.length>0){obj.embeds=msg.embeds.map(embed=>{const mapped={};for(const key of Object.keys(embed)){if(key==="id"){continue}if(key==="rawTitle"){mapped["title"]=embed[key]}else if(key==="rawDescription"){mapped["description"]=embed[key]}else{mapped[key]=embed[key]}}return JSON.stringify(mapped)})}if(msg.reactions.length>0){obj.reactions=msg.reactions.map(reaction=>{const emoji=reaction.emoji;const mapped={count:reaction.count};if(emoji.id){mapped.id=emoji.id}if(emoji.name){mapped.name=emoji.name}if(emoji.animated){mapped.isAnimated=emoji.animated}return mapped})}return obj}));const anyNewMessages=await response.text();return anyNewMessages==="1"}}}();
|
||||
const STATE=function(){let serverPort=-1;let serverToken="";const post=function(endpoint,json){const aborter=new AbortController;const timeout=window.setTimeout(()=>aborter.abort(),5e3);return new Promise(async(resolve,reject)=>{let r;try{r=await fetch("http://127.0.0.1:"+serverPort+endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-DHT-Token":serverToken},credentials:"omit",redirect:"error",body:JSON.stringify(json),signal:aborter.signal})}catch(e){if(e.name==="AbortError"){reject({status:"DISCONNECTED"});return}else{reject({status:"ERROR",message:e.message});return}}finally{window.clearTimeout(timeout)}if(r.status===200){resolve(r);return}try{const message=await r.text();reject({status:"ERROR",message:message})}catch(e){reject({status:"ERROR",message:e.message})}})};const trackingStateChangedListeners=[];let isTracking=false;const addedChannels=new Set;const addedUsers=new Set;return{setup(port,token){serverPort=port;serverToken=token},onTrackingStateChanged(callback){trackingStateChangedListeners.push(callback);callback(isTracking)},isTracking(){return isTracking},setIsTracking(state){if(isTracking!==state){isTracking=state;if(isTracking){addedChannels.clear();addedUsers.clear()}for(const callback of trackingStateChangedListeners){callback(isTracking)}}},async addDiscordChannel(serverInfo,channelInfo){if(addedChannels.has(channelInfo.id)){return}const server={id:serverInfo.id,name:serverInfo.name,type:serverInfo.type};const channel={id:channelInfo.id,name:channelInfo.name};if("extra"in channelInfo){const extra=channelInfo.extra;if("parent"in extra){channel.parent=extra.parent}channel.position=extra.position;channel.topic=extra.topic;channel.nsfw=extra.nsfw}await post("/track-channel",{server:server,channel:channel});addedChannels.add(channelInfo.id)},async addDiscordMessages(channelId,discordMessageArray){discordMessageArray=discordMessageArray.filter(msg=>(msg.type===0||msg.type===19||msg.type===21)&&msg.state==="SENT");if(discordMessageArray.length===0){return false}const userInfo={};let hasNewUsers=false;for(const msg of discordMessageArray){const user=msg.author;if(!addedUsers.has(user.id)){const obj={id:user.id,name:user.username};if(user.avatar){obj.avatar=user.avatar}if(!user.bot){obj.discriminator=user.discriminator}userInfo[user.id]=obj;hasNewUsers=true}}if(hasNewUsers){await post("/track-users",Object.values(userInfo));for(const id of Object.keys(userInfo)){addedUsers.add(id)}}const response=await post("/track-messages",discordMessageArray.map(msg=>{const obj={id:msg.id,sender:msg.author.id,channel:msg.channel_id,text:msg.content,timestamp:msg.timestamp.toDate().getTime()};if(msg.editedTimestamp!==null){obj.editTimestamp=msg.editedTimestamp.toDate().getTime()}if(msg.messageReference!==null){obj.repliedToId=msg.messageReference.message_id}if(msg.attachments.length>0){obj.attachments=msg.attachments.map(attachment=>{const mapped={id:attachment.id,name:attachment.filename,size:attachment.size,url:attachment.url};if(attachment.content_type){mapped.type=attachment.content_type}return mapped})}if(msg.embeds.length>0){obj.embeds=msg.embeds.map(embed=>{const mapped={};for(const key of Object.keys(embed)){if(key==="id"){continue}if(key==="rawTitle"){mapped["title"]=embed[key]}else if(key==="rawDescription"){mapped["description"]=embed[key]}else{mapped[key]=embed[key]}}return JSON.stringify(mapped)})}if(msg.reactions.length>0){obj.reactions=msg.reactions.map(reaction=>{const emoji=reaction.emoji;const mapped={count:reaction.count};if(emoji.id){mapped.id=emoji.id}if(emoji.name){mapped.name=emoji.name}if(emoji.animated){mapped.isAnimated=emoji.animated}return mapped})}return obj}));const anyNewMessages=await response.text();return anyNewMessages==="1"}}}();
|
||||
@@ -8,7 +8,7 @@
|
||||
<Authors>chylex</Authors>
|
||||
<Company>DiscordHistoryTracker</Company>
|
||||
<Product>DiscordHistoryTrackerServer</Product>
|
||||
<Version>31.0.0.0</Version>
|
||||
<Version>32.0.0.0</Version>
|
||||
<AssemblyVersion>$(Version)</AssemblyVersion>
|
||||
<FileVersion>$(Version)</FileVersion>
|
||||
<PackageVersion>$(Version)</PackageVersion>
|
||||
|
||||
Reference in new issue
Block a user