QQ邮箱增强

Violentmonkey Scripts

当前为 2023-05-02 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        QQ邮箱增强
// @namespace   Violentmonkey Scripts
// @match       *://mail.qq.com/*
// @grant       none
// @version     XiaoYing_2023.05.08
// @grant       GM_info 
// @grant       GM_getValue
// @grant       GM_setValue
// @grant       GM_addStyle
// @grant       GM_deleteValue
// @grant       GM_xmlhttpRequest
// @grant       GM_setClipboard
// @grant       GM_registerMenuCommand
// @grant       GM_unregisterMenuCommand
// @grant       GM_getResourceText
// @grant       GM_getResourceURL
// @grant       GM_openInTab
// @grant       unsafeWindow
// @run-at      document-start
// @author      github.com @XiaoYingYo
// @require     https://greasyfork.org/scripts/464929-module-jquery-xiaoying/code/module_jquery_XiaoYing.js
// @require     https://greasyfork.org/scripts/464780-global-module/code/global_module.js
// @description Violentmonkey Scripts
// ==/UserScript==

var global_module = window["global_module"];

var Func = new Map();
Func.set("delMail", async function () {
    let op = await global_module.waitForElement("div[class^='dialog_operate']", null, null);
    let confirm = $(op).find("a").eq(0);
    global_module.clickElement(confirm[0]);
});
Func.set("frame_html.html", async function () {
    window.addEventListener("message", function (event) {
        let data = event.data;
        if (data.origin !== "QQ邮箱增强") {
            return;
        };
        let func = data.func;
        if (!Func.has(func)) {
            return;
        }
        Func.get(func)();
    }, false);
    let clearRecycleBin = async function () {
        let folder_5 = $("li[id='folder_5_td']").eq(0);
        let a = folder_5.find("a");
        if (a.length === 1) {
            return;
        }
        $(a[1]).on("click", async function () {
            console.log("delMail");
            Func.get("delMail")();
        });
    }
    let observer = new MutationObserver(function (mutations) {
        for (let mutation of mutations) {
            let Element = mutation.target;
            let id = $(Element).attr("id");
            if (id !== "navMidBar") {
                continue;
            }
            clearRecycleBin();
            return;
        }
    });
    clearRecycleBin();
    let navMidBar = await global_module.waitForElement("div#navMidBar", null, null, -1);
    observer.observe(navMidBar.eq(0)[0], { childList: true, subtree: true });
});
Func.set("readmail.html", async function () {
    let delMail = await global_module.waitForElement("a[ck='delMail'][opt]", null, null, -1);
    for (let i = 0; i < delMail.length; i++) {
        let Item = delMail[i];
        $(Item).on("click", async function () {
            window.parent.postMessage({ origin: "QQ邮箱增强", func: 'delMail' }, "*");
        });
    }
});
Func.set("mail_list.html", async function () {
    let delMail = await global_module.waitForElement("a[id='quick_completelydel'][class]", null, null, -1);
    for (let i = 0; i < delMail.length; i++) {
        let Item = delMail[i];
        $(Item).on("click", async function () {
            window.parent.postMessage({ origin: "QQ邮箱增强", func: 'delMail' }, "*");
        });
    }
});

(async function () {
    let path = window.location.pathname;
    let last = path.lastIndexOf("/");
    let name = path.substring(last + 1) + ".html";
    if (!Func.has(name)) {
        return;
    }
    Func.get(name)();
})();