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.  
  14. // ==UserScript==
  15. // @name GMail Basic HTML Enhancement
  16. // @namespace http://allencch.wordpress.com
  17. // @description Enhance GMail Basic HTML with "select all"
  18. // @include https://mail.google.com/mail/*/h/*
  19. // @include https://mail.google.com/mail/h/*
  20. // @version 1.2
  21. // ==/UserScript==
  22.  
  23.  
  24. gmSelect = function(check) {
  25. var inputs = document.getElementsByTagName('input');
  26. for(var i=0;i<inputs.length;i++) {
  27. if(inputs[i].type == 'checkbox') {
  28. inputs[i].checked = check;
  29. }
  30. }
  31. }
  32.  
  33. gmSelectCheck = function() {
  34. select = this.innerHTML;
  35. if(select == "Select All")
  36. gmSelect(true);
  37. else
  38. gmSelect(false);
  39. }
  40.  
  41.  
  42. window.gmFunction = function() {
  43. var anchors,newElement;
  44. anchors = document.getElementsByTagName('a');
  45. var refresh = new Array();
  46.  
  47. newElement = document.createElement('div');
  48. newElement.setAttribute('name','gm_elem');
  49. //Find all the refresh
  50. for(var i=0,j=0;i<anchors.length;i++) {
  51. if(anchors[i].innerHTML.search(/Refresh/) >= 0) {
  52. anchors[i].parentNode.insertBefore(newElement.cloneNode(true),anchors[i].nextSibling);
  53. }
  54. }
  55. var gmElem = document.getElementsByName('gm_elem');
  56. for(var i=0;i<gmElem.length;i++) {
  57. gmElem[i].innerHTML = '<a name="gm_select" href="javascript:">Select All</a> ';
  58. gmElem[i].innerHTML += '<a name="gm_select" href="javascript:">Select None</a>';
  59. }
  60. //Using addEventListener() to solve the Chromium problem
  61. var select = document.getElementsByName('gm_select');
  62. for(var i=0;i<select.length;i++) {
  63. select[i].addEventListener('click',gmSelectCheck,false);
  64. }
  65. }
  66.  
  67. window.setTimeout(gmFunction(),1*1000);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址