🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/30 12:58:48
🔄 下次更新时间:2026/01/30 13:58:48
手动刷新缓存

Gmail Label Hider (pref-based)

Hide certain Gmail labels

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name           Gmail Label Hider (pref-based)
// @namespace      http://www.arthaey.com
// @description    Hide certain Gmail labels
// @include        http://gmail.google.com/*
// @include        https://gmail.google.com/*
// @include        http://mail.google.com/*
// @include        https://mail.google.com/*
// @version        1.3
//
// Backed up from http://userscripts.org/scripts/review/11774
// Last updated on 2007-08-29
//
// Based on Ben Hengst's Gmail Label Hider v0.02
// License: http://creativecommons.org/licenses/GPL/2.0/
//
// HOW TO USE:
//
// Right-click on the Greasemonkey monkey-face to access the "User Script
// Commands" menu. Select the "Set list of Gmail labels to hide" menu item.
//
// At the prompt, type in the list of Gmail labels you want to hide, separated
// by the "|" (pipe) character.
//
// KNOWN BUGS:
//
// - Sometimes the labels don't hide themselves when you open a message. I
//   haven't yet investigated why this is happening.
//
// CHANGELOG:
//
// v1.3 - made label names case-insenstive ("drafts" and "Drafts" are the same)
// v1.2 - added ability to hide non-label things like Starred, Drafts, etc.
// v1.1 - added "Show All" and "Hide Some" toggle links
// v1.0 - initial release
//
// ==/UserScript==

(function () {

   var TOGGLE_ID = "NavBar_Labels_ToggleLink";

   function setLabelList() {
       var hideList = GM_getValue('hideList', null);
       var list = prompt("List of labels to hide, separated by '|'", hideList);
       if (list && list != hideList) {
           GM_setValue('hideList', list);
           window.location.reload(false);
       }
   }

   function hideLabels() {
       var hideList = GM_getValue('hideList', null);
       if (!hideList) return;

       var hideLabels = hideList.split('|');
       var allDivs = document.evaluate(
          "//div[@class='lk cs'] | //div[@class='nl']",
          document,
          null,
          XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
          null);

       for (var i = 0; i < allDivs.snapshotLength; i++) {
          var thisDiv = allDivs.snapshotItem(i);

          for (var j = 0; j < hideLabels.length; j++) {
             var regex = new RegExp("^" + hideLabels[j], "i");

             if (thisDiv.textContent.match(regex)) {
                thisDiv.style.display = "none";
                break;
             }
          }
       }

       toggleLink();
   }

   function showLabels() {
       var allDivs = document.evaluate(
          "//div[@class='lk cs'] | //div[@class='nl']",
          document,
          null,
          XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
          null);

       for (var i = 0; i < allDivs.snapshotLength; i++) {
          var thisDiv = allDivs.snapshotItem(i);
          thisDiv.style.display = "block";
       }

       toggleLink();
   }

   function addLink() {
       var editLabelsDiv = document.getElementById("prf_l");
       if (!editLabelsDiv) return;

       var link = document.createElement("div");
       link.id = TOGGLE_ID;
       link.className = "lk cs";
       link.style.textAlign = "right";
       toggleLink(link);
       editLabelsDiv.parentNode.insertBefore(link, editLabelsDiv);
   }

   function toggleLink(linkObj) {
       var link = linkObj;
       if (!link) link = document.getElementById(TOGGLE_ID);
       if (!link) return;

       if (link.innerHTML.match(/Hide/)) {
           link.innerHTML = "Show All";
           link.removeEventListener('click', hideLabels, true);
           link.addEventListener('click', showLabels, true);
       }
       else {
           link.innerHTML = "Hide Some";
           link.removeEventListener('click', showLabels, true);
           link.addEventListener('click', hideLabels, true);
       }
   }

   window.addEventListener('load', function() {
       GM_registerMenuCommand("Set list of Gmail labels to hide", setLabelList);
       addLink();
       hideLabels();
   }, true);

})();