QQ邮箱增强

Violentmonkey Scripts

目前為 2023-05-02 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        QQ邮箱增强
// @namespace   Violentmonkey Scripts
// @match       *://mail.qq.com/*
// @grant       none
// @version     XiaoYing_2023.05.10
// @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)();
})();