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;
};
@No-Eul
Copy link
Author

No-Eul commented Jan 4, 2021

Copy this code, and paste into the console of your browser or Discord client!

Before applying this userscript, It's recommended you should read this gist. The gist includes how to apply the userscript and what to do before applying.

이 코드를 복사해서 당신의 브라우저나 디스코드 콘솔에 붙여넣으세요!

유저스크립트를 적용하기 전에 본 Gist를 읽어보는 것이 좋습니다. 여기에는 유저스크립트를 적용하는 방법과 적용하기 전 사전 작업에 대한 내용이 포함되어 있습니다.

@williameom5678
Copy link

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

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