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

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

Gmail Label Hider (pref-based)

Hide certain Gmail labels

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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

公众号二维码

扫码关注【爱吃馍】

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

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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

公众号二维码

扫码关注【爱吃馍】

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

// ==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);

})();