Neopets Neomail Manager

Adds a checkbox to mark "spammy" neomail messages for deletion (you still need to click "Go" to confirm the action).

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Neopets Neomail Manager
// @version      1.0
// @description  Adds a checkbox to mark "spammy" neomail messages for deletion (you still need to click "Go" to confirm the action).
// @author       darknstormy
// @match        https://www.neopets.com/neomessages.phtml*folder=Inbox
// @icon         https://www.google.com/s2/favicons?sz=64&domain=neopets.com
// @grant        none
// @license      MIT
// @namespace https://greasyfork.org/users/1328929
// ==/UserScript==

addSpamCheckbox()

function checkSpamMessages(markForDeletion) {
    var spamMessagesFound = false

    $('form[name="messages"] table tr td:nth-child(4) a').each(function() {
        var messageSubject = $(this).prop("innerText") // remove the <b> tags for comparing our subjects to the spam filter

        if (SPAM_SUBJECT_LINES.find((element) => messageSubject === element)) {
            $(this).parent().parent().find("td:nth-child(1) input").prop('checked', markForDeletion);
            spamMessagesFound = true
        }
    });

    if (!spamMessagesFound) {
        return
    }

    if (markForDeletion) {
        $('select[name="action"]').val("Delete Messages").change()
    } else {
        $('select[name="action"]').val('').change()
    }
}

function addSpamCheckbox() {
    $('form[name="messages"] table tr:last td:last').attr('colspan',2);
    $('form[name="messages"] table tr:last td:first').after('<td colspan="1" bgcolor="#DEDEDE" align="left" valign="middle"><input type="checkbox" name="check_spam"> Check Spam</td>')
    $('input[name="check_spam"]').on('click', function () {
        checkSpamMessages($(this).is(":checked"))
    })
}

const SPAM_SUBJECT_LINES = [
    "Special Reward Unlocked!",
    "Faerie Fragments Reward Unlocked!",
    "Hi"
]