autounping

4/21/2021, 6:00:42 PM

// ==UserScript==
// @name        autounping
// @namespace   Violentmonkey Scripts
// @match       *://discord.com/*
// @grant       none
// @version     1.1
// @author      -
// @description 4/21/2021, 6:00:42 PM
// @noframes
// ==/UserScript==

/* jshint esversion: 6 */

let didManuallyClick = false;
function unping() {
    const mentionButtons = document.querySelectorAll('[aria-label="Mention"]');
    if(mentionButtons.length > 0) {
        const grandparent = mentionButtons[0].parentNode.parentNode;
        if(!didManuallyClick && grandparent.getAttribute('aria-checked') == 'true') {
            console.log('unpinging');
            grandparent.click();
            grandparent.addEventListener('click', function(_) {
                didManuallyClick = true;
            });
        }
    } else {
      didManuallyClick = false;
    }
}
setInterval(unping, 500)