Gmail Filter From Email Button

Adds a "Filter All" button to the left of the received time on gmail emails. Clicking it does the same thing as the "filter messages like this" menu button.

当前为 2024-01-12 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Gmail Filter From Email Button
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds a "Filter All" button to the left of the received time on gmail emails. Clicking it does the same thing as the "filter messages like this" menu button.
// @author       Patrick Daniel
// @match        https://mail.google.com/mail/u/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant        none
// @require      https://code.jquery.com/jquery-3.7.0.min.js
// @license MIT
// ==/UserScript==

(function() {
    //'use strict';
    const NewEL = (tag, prop) => Object.assign(document.createElement(tag), prop);

    document.addEventListener("mousemove", e => {
        //$(document).on("click mousedown mouseup focus blur keydown change", console.log("move"));
        //console.log($(".gH.bAk"));

        if(document.querySelector(".gH.bAk span") && !document.querySelector(".gH.bAk span button")){
            var email = document.querySelector(".go")?.textContent?.replace('<', '')?.replace('>', '');
            var url = `https://mail.google.com/mail/u/1/#create-filter/from=${encodeURIComponent(email)}&sizeoperator=s_sl&sizeunit=s_smb`
            const EL_btn = NewEL("button", {
                textContent: "Filter All",
                onclick() {
                    window.location.href = url;
                    //window.open(url);
                    //window.focus();
                    //window.open(url, '_blank');
                },
            });
            $(document.querySelector(".gH.bAk span")).prepend(EL_btn);
        }
        if(document.querySelector(".gH.bAk span button").attributes.length == 0){
            document.querySelector(".gH.bAk span button").setAttribute('style', `border-radius: 10px; font-size: medium; margin: 0 5px; border: solid #cdcdcd 1px; background: #f1f1f1; padding: 3px 13px;`)
        }
    })

    /*const observer = new MutationObserver(m => {
        console.log(m);
        console.log($)
    });
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });*/
})();