Skip to content

Instantly share code, notes, and snippets.

@No-Eul
Last active July 23, 2024 06:25
Show Gist options
  • Save No-Eul/502f0941e7bfca4881cc12a7303b6d2a to your computer and use it in GitHub Desktop.
Save No-Eul/502f0941e7bfca4881cc12a7303b6d2a to your computer and use it in GitHub Desktop.
Set to disable reply ping to default
(this.disablePingToDefault = () => {
this.disablePingToDefault.interval = setInterval(() => {
if (this.disablePingToDefault.currentUrl !== location.href) { // Cached url is not equal to 'location.href', do the following:
if (this.disablePingToDefault.observer !== undefined) // If an observer which created at previous is exist,
this.disablePingToDefault.observer.disconnect(); // disconnect it.
else { // If it wasn't,
// Create new instance to detect insertion of the reply box.
this.disablePingToDefault.observer = new MutationObserver(() => {
let pingButton = document.querySelector('div[class*="mentionButton"]'); // Get ping switch in reply box.
if (pingButton !== null) pingButton.click(); // Click if it's not null. Then reply ping will be disable.
});
}
let channelTextArea = document.querySelector('div[class*="channelTextArea_"]'); // Get the chat box.
if (channelTextArea !== null) // If the chat box exist,
// Observe that reply box was created above the chat box.
this.disablePingToDefault.observer.observe(channelTextArea, { childList: true, subtree: true });
this.disablePingToDefault.currentUrl = location.href; // Then cache current url.
}
}, 50); // I have set 50 millis delay for waiting time. This task will be run every 50 milliseconds.
})();
// This function changes to original setting; If you want to change it that way, you can run 'enablePingToDefault();' into the console.
this.enablePingToDefault = () => {
clearInterval(this.disablePingToDefault.interval);
this.disablePingToDefault.observer.disconnect();
delete this.disablePingToDefault;
delete this.enablePingToDefault;
};
@williameom5678
Copy link

이제 이것을 BetterDiscord 플러그인으로 개조해 보겠습니다?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment