GGn Ignore Requests

Ignore requests

// ==UserScript==
// @name         GGn Ignore Requests
// @namespace    none
// @version      1
// @description  Ignore requests
// @author       ingts
// @match        https://gazellegames.net/requests.php*
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// ==/UserScript==
if (location.href.includes('action=view')) {
    const id = new URL(location.href).searchParams.get('id')
    let ignored = GM_getValue(id)
    const button = document.createElement('a')
    button.href = 'javascript:'
    button.className = 'brackets'
    button.textContent = ignored ? ' Unignore ' : ' Ignore '
    document.querySelector('div.linkbox').append(button)
    button.onclick = () => {
        if (ignored) {
            GM_deleteValue(id)
            button.textContent = ' Ignore '
            ignored = false
        } else {
            GM_setValue(id, 1)
            button.textContent = ' Unignore '
            ignored = true
        }
    }
} else {
    document.querySelectorAll('#requests_list tr:not(.colhead_dark)').forEach(row => {
        if (GM_getValue(/\d+/.exec(row.querySelector('a').href)[0])) row.remove()
    })
}