🏠 返回首頁 

Greasy Fork is available in English.

GMail Basic HTML Enhancement

Enhance GMail Basic HTML with "select all"

  1. /**
  2. * @version 1.2
  3. * @author Allen Choong
  4. * @created 2010-09-25
  5. *
  6. * Enhance GMail Basic HTML with "select all"
  7. *
  8. * Changelog:
  9. * 2013-05-03 1.2 Add the include for multiple login
  10. * 2010-10-01 1.1 Using addEventListener() to solve the problem for Google Chrome, because
  11. * Chrome does not use the unsafeWindow as the source. Thus, now compatible to both Firefox and Chrome
  12. */
  13. // ==UserScript==
  14. // @name GMail Basic HTML Enhancement
  15. // @namespace http://allencch.wordpress.com
  16. // @description Enhance GMail Basic HTML with "select all"
  17. // @include https://mail.google.com/mail/*/h/*
  18. // @include https://mail.google.com/mail/h/*
  19. // @version 1.2
  20. // ==/UserScript==
  21. gmSelect = function(check) {
  22. var inputs = document.getElementsByTagName('input');
  23. for(var i=0;i<inputs.length;i++) {
  24. if(inputs[i].type == 'checkbox') {
  25. inputs[i].checked = check;
  26. }
  27. }
  28. }
  29. gmSelectCheck = function() {
  30. select = this.innerHTML;
  31. if(select == "Select All")
  32. gmSelect(true);
  33. else
  34. gmSelect(false);
  35. }
  36. window.gmFunction = function() {
  37. var anchors,newElement;
  38. anchors = document.getElementsByTagName('a');
  39. var refresh = new Array();
  40. newElement = document.createElement('div');
  41. newElement.setAttribute('name','gm_elem');
  42. //Find all the refresh
  43. for(var i=0,j=0;i<anchors.length;i++) {
  44. if(anchors[i].innerHTML.search(/Refresh/) >= 0) {
  45. anchors[i].parentNode.insertBefore(newElement.cloneNode(true),anchors[i].nextSibling);
  46. }
  47. }
  48. var gmElem = document.getElementsByName('gm_elem');
  49. for(var i=0;i<gmElem.length;i++) {
  50. gmElem[i].innerHTML = '<a name="gm_select" href="javascript:">Select All</a> ';
  51. gmElem[i].innerHTML += '<a name="gm_select" href="javascript:">Select None</a>';
  52. }
  53. //Using addEventListener() to solve the Chromium problem
  54. var select = document.getElementsByName('gm_select');
  55. for(var i=0;i<select.length;i++) {
  56. select[i].addEventListener('click',gmSelectCheck,false);
  57. }
  58. }
  59. window.setTimeout(gmFunction(),1*1000);