GMail Basic HTML Enhancement

Enhance GMail Basic HTML with "select all"

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/**
 * @version	1.2
 * @author	Allen Choong
 * @created	2010-09-25
 *
 * Enhance GMail Basic HTML with "select all"
 *
 * Changelog:
 * 2013-05-03	1.2		Add the include for multiple login
 * 2010-10-01	1.1		Using addEventListener() to solve the problem for Google Chrome, because
 * Chrome does not use the unsafeWindow as the source. Thus, now compatible to both Firefox and Chrome
 */

// ==UserScript==
// @name           GMail Basic HTML Enhancement
// @namespace      http://allencch.wordpress.com
// @description    Enhance GMail Basic HTML with "select all"
// @include        https://mail.google.com/mail/*/h/*
// @include        https://mail.google.com/mail/h/*
// @version	1.2
// ==/UserScript==


gmSelect = function(check) {
	var inputs = document.getElementsByTagName('input');
	for(var i=0;i<inputs.length;i++) {
		if(inputs[i].type == 'checkbox') {
			inputs[i].checked = check;
		}
	}
}

gmSelectCheck = function() {
	select = this.innerHTML;
	if(select == "Select All")
		gmSelect(true);
	else
		gmSelect(false);
}


window.gmFunction = function() {
	var anchors,newElement;	
	anchors = document.getElementsByTagName('a');
	
	var refresh = new Array();
	

	newElement = document.createElement('div');
	newElement.setAttribute('name','gm_elem');
	
	
	//Find all the refresh
	for(var i=0,j=0;i<anchors.length;i++) {
		if(anchors[i].innerHTML.search(/Refresh/) >= 0) {
			anchors[i].parentNode.insertBefore(newElement.cloneNode(true),anchors[i].nextSibling);
		}
	}
	
	
	var gmElem = document.getElementsByName('gm_elem');
	for(var i=0;i<gmElem.length;i++) {
		gmElem[i].innerHTML = '<a name="gm_select" href="javascript:">Select All</a> ';
		gmElem[i].innerHTML += '<a name="gm_select" href="javascript:">Select None</a>';
	}
	
	//Using addEventListener() to solve the Chromium problem
	var select = document.getElementsByName('gm_select');
	for(var i=0;i<select.length;i++) {
		select[i].addEventListener('click',gmSelectCheck,false);
	}
}

window.setTimeout(gmFunction(),1*1000);