-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
169 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
function discordParse(wordlist) { | ||
let decryptedTexts = []; | ||
|
||
const chatArea = document.querySelector('.chatContent_a7d72e'); | ||
if (!chatArea) return decryptedTexts; | ||
|
||
chatArea.querySelectorAll('[id^="chat-messages-"]').forEach(messageElement => { | ||
const decryptedText = decryptElement(messageElement, wordlist); | ||
if (decryptedText) decryptedTexts.push(decryptedText); | ||
if (decryptedTexts.length >= 10) return; | ||
}); | ||
|
||
return decryptedTexts; | ||
} | ||
|
||
function decryptElement(messageElement, wordlist) { | ||
try { | ||
const contentElement = messageElement.querySelector('[id^="message-content-"]'); | ||
if (!contentElement) return null; | ||
|
||
const originalText = contentElement.textContent.trim(); | ||
let decryptedText = originalText; | ||
|
||
for (const [key, value] of Object.entries(wordlist)) { | ||
decryptedText = decryptedText.replace(new RegExp(escapeRegExp(value), 'g'), key); | ||
} | ||
|
||
if (decryptedText !== originalText) { | ||
const usernameElement = messageElement.querySelector('[class*="username_"]'); | ||
const timestampElement = messageElement.querySelector('time'); | ||
|
||
const username = usernameElement ? usernameElement.textContent.trim() : 'Unknown User'; | ||
const timestamp = timestampElement ? timestampElement.getAttribute('aria-label') : ''; | ||
|
||
return `${username}: ${decryptedText} - ${timestamp}`; | ||
} | ||
|
||
return null; | ||
} catch (error) { | ||
console.error("Error in decryptElement: ", error); | ||
return null; | ||
} | ||
} | ||
|
||
function escapeRegExp(string) { | ||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters