GMail Basic HTML Enhancement

Enhance GMail Basic HTML with "select all"

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

/**
 * @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);