GaiaOnline: Mail Checker

Checks inboxes for mail (Tools->Greasemonkey->User Script Commands)

  1. // ==UserScript==
  2. // @name GaiaOnline: Mail Checker
  3. // @namespace http://userscripts.org/users/62850
  4. // @description Checks inboxes for mail (Tools->Greasemonkey->User Script Commands)
  5. // @include *
  6. // @grant GM_getValue
  7. // @grant GM_setValue
  8. // @grant GM_xmlhttpRequest
  9. // @grant GM_registerMenuCommand
  10. // @version 0.0.1.20150301153417
  11. // ==/UserScript==
  12. function getMail(userN,mode){
  13. GM_xmlhttpRequest({
  14. method: "GET",
  15. url: 'http://www.gaiaonline.com/chat/gsi/index.php?v=json&m=[[102%2C['+userN+']]]&X='+(new Date().getTime().toString().substring(0, 10)),
  16. onload: function(r){
  17. if(typeof JSON != 'undefined'){
  18. var json=JSON.parse(r.responseText);
  19. }
  20. else{
  21. var json=eval(r.responseText);
  22. }
  23. var pms=json[0][2]['user_pms'];
  24. if(mode=='add'){
  25. try{
  26. alert(json[0][2]['username']+' ('+userN+') has been added there are '+pms+' unread PM(s).');
  27. save(userN,pms);
  28. }
  29. catch(e){
  30. alert('Check the user id\nError code:\n'+e);
  31. }
  32. }
  33. else if(mode=='del'){
  34. try{
  35. var userName=json[0][2]['username'];
  36. if(confirm('Click OK to remove '+userName+' ('+userN+')')===true){
  37. alert(userName+' ('+userN+') has been removed.');
  38. delete arr[userN];
  39. GM_setValue('id',JSON.stringify(arr));
  40. }
  41. }
  42. catch(e){
  43. alert('Check the user id ('+userN+')\nError code:\n'+e);
  44. }
  45. }
  46. else if(mode=='all'){
  47. alert(json[0][2]['username']+' ('+userN+') has '+pms+' unread PM(s).');
  48. }
  49. else{
  50. if(pms>0){
  51. if(GM_getValue(userN)!=pms){
  52. alert(json[0][2]['username']+' ('+userN+') has '+pms+' unread PM(s).');
  53. save(userN,pms);
  54. }
  55. }
  56. else if(GM_getValue(userN)!=pms){
  57. save(userN,pms);
  58. }
  59. }
  60. }
  61. });
  62. }
  63. function getIdList(){
  64. var i,str='';
  65. for(i in arr)
  66. str+='\n'+i
  67. alert('User Ids:'+str);
  68. }
  69. function addUser(){
  70. var id=prompt('What is the user ID?');
  71. if(id){
  72. if(Number(id)==id){
  73. getMail(id,'add');
  74. }
  75. else{
  76. alert('User IDs are numbers\n'+id+'is not a number');
  77. }
  78. }
  79. }
  80. function delUser(){
  81. var id=prompt('What is the user ID?');
  82. if(id){
  83. if(Number(id)==id){
  84. getMail(id,'del');
  85. }
  86. else{
  87. alert('User IDs are numbers\n'+id+'is not a number');
  88. }
  89. }
  90. }
  91. function save(id,mail){
  92. arr[id]=mail;
  93. GM_setValue('id',JSON.stringify(arr));
  94. }
  95. function getAllMail(){
  96. for(var i in arr){
  97. getMail(i,'all');
  98. }
  99. }
  100. var isInIFrame,arr;
  101. try{
  102. isInIFrame=window.location!=top.location;
  103. }
  104. catch(e){
  105. isInIFrame=true;
  106. }
  107. if(isInIFrame===false){
  108. arr=GM_getValue('id');
  109. if(document.domain!='www.gaiaonline.com'&&arr){
  110. arr=arr?JSON.parse(arr):{};
  111. for(var i=0;i<arr.length;i++){
  112. getMail(arr[i],'get');
  113. }
  114. }
  115. else if(arr){
  116. arr=arr?JSON.parse(arr):{};
  117. try{
  118. f();
  119. var id=document.getElementsByClassName('panel_mygaia_profile')[0].getElementsByTagName('a')[0].href.split('/');
  120. id=id[id.length-2];
  121. if(isNaN(id)){
  122. makeError();
  123. }
  124. }
  125. catch(e){
  126. try{
  127. var id=document.evaluate('.//a[@title="Logout from your Gaia account"]',document,null,9,null).singleNodeValue.href;
  128. id=id.substr(id.indexOf('userid=')+7);
  129. if(id.indexOf('&')!=-1){
  130. id=id.substr(0,id.indexOf('&'));
  131. }
  132. }
  133. catch(e){
  134. try{
  135. var id=document.getElementById('gmSelectLogin').className;
  136. if(id!=Number(id)){
  137. id='';
  138. }
  139. }
  140. catch(e){}
  141. }
  142. }
  143. if(id){
  144. while(id!=Number(id)){
  145. id=id.substr(-1);
  146. }
  147. }
  148. for(var i in arr){
  149. if(id){
  150. if(i!=id){
  151. getMail(i,'get');
  152. }
  153. else if(!arr[id]){
  154. save(id,0);
  155. }
  156. }
  157. else{
  158. getMail(i,'get');
  159. }
  160. }
  161. }
  162. else
  163. arr={};
  164. GM_registerMenuCommand("Gaia Mail Checker: List all user ids", getIdList);
  165. GM_registerMenuCommand("Gaia Mail Checker: Add user", addUser);
  166. GM_registerMenuCommand("Gaia Mail Checker: Remove user", delUser);
  167. GM_registerMenuCommand("Gaia Mail Checker: Get all mail", getAllMail);
  168. }

QingJ © 2025

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