-
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.
wording changes, auto-saving and other minor changes.
- Loading branch information
Showing
6 changed files
with
158 additions
and
135 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 |
---|---|---|
@@ -1,47 +1,53 @@ | ||
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 discordParse(codebook) { | ||
let decryptedTexts = []; | ||
|
||
const chatArea = document.querySelector('.chatContent_a7d72e'); | ||
if (!chatArea) return decryptedTexts; | ||
|
||
const messageElements = chatArea.querySelectorAll('[id^="chat-messages-"]'); | ||
for (let i = 0; i < messageElements.length; i++) { | ||
const decryptedText = decryptElement(messageElements[i], codebook); | ||
if (decryptedText) { | ||
decryptedTexts.push(decryptedText); | ||
if (decryptedTexts.length >= 10) break; | ||
} | ||
} | ||
|
||
function decryptElement(messageElement, wordlist) { | ||
try { | ||
|
||
return decryptedTexts; | ||
} | ||
|
||
function decryptElement(messageElement, codebook) { | ||
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); | ||
|
||
for (const key in codebook) { | ||
if (Object.prototype.hasOwnProperty.call(codebook, key)) { | ||
const value = codebook[key]; | ||
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}`; | ||
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) { | ||
} catch (error) { | ||
console.error("Error in decryptElement: ", error); | ||
return null; | ||
} | ||
} | ||
|
||
function escapeRegExp(string) { | ||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
} | ||
} | ||
|
||
function escapeRegExp(string) { | ||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
} |
Oops, something went wrong.