Neopets Neomail Manager

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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"
]