NFTFlip 自动邮件提醒脚本

基于nftflip.ai平台的自动发送邮件插件脚本代码透明无任何钱包秘钥问题。因为作者老是错过nft出货时间,这个脚本诞生了。后期会考虑加入其它发送邮件的条件

  1. // ==UserScript==
  2. // @name NFTFlip 自动邮件提醒脚本
  3. // @namespace 成都3年java开发找工作,要人的联系我啊!作者还没班上!!
  4. // @version 0.0.3
  5. // @description 基于nftflip.ai平台的自动发送邮件插件脚本代码透明无任何钱包秘钥问题。因为作者老是错过nft出货时间,这个脚本诞生了。后期会考虑加入其它发送邮件的条件
  6. // @author JingMaster Twitter:@EEck16 群内昵称:靖靖靖
  7. // @match https://review.nftflip.ai/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=nftflip.ai
  9. // @grant none
  10. // @require https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js
  11. // @require https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js
  12. // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. //全局变量
  17. //定义时间对象
  18. let time = new Date();
  19. //定义上一封邮件发送的日期
  20. var startSendMailDate = '1990/1/1 00:00:00';
  21. //现在的日期;
  22. var nowTime='';
  23. //定义是否需要发送邮件
  24. var isSend = false;
  25. //发送的间隔
  26. var timeInterval='';
  27. //发送短信/控制台输出前缀(自定义)
  28. var msg='您拥有的NFT 实时排名<br>\n';
  29. //定义发送短信排名(不包括)
  30. var rank = 5;
  31. //定义邮件时间间隔(分钟)
  32. var mailTime=15;
  33. //定义轮询间隔(毫秒,可自定义 推荐10000 1s=1000ms)
  34. var executeTime=10000;
  35. //接收者邮箱(需要更改)
  36. var to ='@qq.com';
  37. //发送者邮箱(需要跟你SMTP注册的邮箱地址一样)
  38. var from = '@gmail.com';
  39. //smtp服务秘钥(自己用自己的最好)
  40. var secureToken='';
  41. //邮件主题(自定义)
  42. var subject= 'Nft出货自动提醒!!!';
  43. //邮件内容(自定义 弃用)
  44. //var mailBody = `<span>该出货了,该出货了<br/>\n`+msg+`<br/></span>`;
  45. //控制台输出打印排名提醒(设定为true开启控制台输出)
  46. var consoleStatus = false;
  47. //请不要修改以下代码
  48. var Email = {
  49. send: function (a)
  50. { return new Promise(function (n, e)
  51. { a.nocache = Math.floor(1e6 * Math.random() + 1), a.Action = "Send"; var t = JSON.stringify(a); Email.ajaxPost("https://smtpjs.com/v3/smtpjs.aspx?", t, function (e) { n(e) }) })
  52. }, ajaxPost: function (e, n, t)
  53. { var a = Email.createCORSRequest("POST", e); a.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), a.onload = function () { var e = a.responseText; null != t && t(e) }, a.send(n) }
  54. , ajax: function (e, n) { var t = Email.createCORSRequest("GET", e); t.onload = function () {
  55. var e = t.responseText; null != n && n(e) }, t.send() }, createCORSRequest: function (e, n) {
  56. var t = new XMLHttpRequest; return "withCredentials" in t ? t.open(e, n, !0) : "undefined" != typeof XDomainRequest ? (t = new XDomainRequest).open(e, n) : t = null, t } };
  57.  
  58.  
  59. setInterval(function () {
  60. var itemClass = document.getElementsByClassName("bar-t-green-c");
  61. var s=$(itemClass[0]).parent().parent().children("td").eq(0).text();
  62. if(itemClass.length==0){
  63. let atime = new Date();
  64. if(consoleStatus==true){
  65. console.log(atime.toLocaleString()+'\n没有监控到拥有的nft进入排行榜');
  66. console.log('上一次邮件提醒时间为'+startSendMailDate);
  67. }
  68. return;
  69. }
  70. var itemArr = [];
  71. for(var i = 0; i< itemClass.length; i++){
  72. itemArr.push(itemClass[i]);
  73. }
  74. var numList = [];
  75. for(var j = 0; j< itemArr.length; j++){
  76. numList.push($(itemArr[j]).parent().parent().children("td").eq(0).text());
  77. numList.push($(itemArr[j]).parent().parent().children("td").eq(3).text());
  78. numList.push($(itemArr[j]).parent().parent().children("td").eq(4).text());
  79. }
  80. for(var k= 0; k< numList.length; k++){
  81. if(k==0){
  82. msg+=numList[k]+'名 【';
  83. msg+=document.getElementsByClassName('ant-radio-button-wrapper ant-radio-button-wrapper-checked')[0].children[1].innerText+'内交易次数:'+numList[k+1];
  84. msg+='当前地板价'+numList[k+2]+'】<br>\n';
  85. if(numList[k]<rank){
  86. isSend=true;
  87. }
  88. }else if(k%3==0){
  89. msg+=numList[k]+'名 【';
  90. msg+=document.getElementsByClassName('ant-radio-button-wrapper ant-radio-button-wrapper-checked')[0].children[1].innerText+'内交易次数:'+numList[k+1];
  91. msg+='当前地板价'+numList[k+2]+'】<br>\n';
  92. if(numList[k]<rank){
  93. isSend=true;
  94. console.log('此处设为true'+isSend)
  95. }
  96. }
  97. }
  98. if(consoleStatus==true){
  99. console.log(msg+'\n上一次邮件提醒时间为'+startSendMailDate)
  100. }
  101. if(isSend){
  102. let nowtime = new Date()
  103. nowTime=nowtime.toLocaleString();
  104. timeInterval = GetDateDiff(startSendMailDate,nowTime,'\/1000\/60')/1000/60;
  105. //console.log('发送邮件间隔时间'+timeInterval);
  106. if(timeInterval<mailTime){
  107. msg='您拥有的NFT 实时排名<br>\n';
  108. return;
  109. }
  110. let aftertime = new Date()
  111. startSendMailDate = aftertime.toLocaleString();
  112. sendEmailToMe(msg);
  113. console.log(startSendMailDate+'\n已发送到+'+to+'+邮件箱提醒')
  114. isSend=false;
  115. }
  116. msg='您拥有的NFT 实时排名<br>\n';
  117. }, executeTime);
  118.  
  119. //时间比较(yyyy-MM-dd HH:mm:ss)
  120. function GetDateDiff(startTime, endTime, diffType) {
  121. startTime = startTime.replace(/\-/g, "/");
  122. endTime = endTime.replace(/\-/g, "/");
  123. diffType = diffType.toLowerCase();
  124. var sTime =new Date(startTime);
  125. var eTime =new Date(endTime);
  126. var timeType =1;
  127. switch (diffType) {
  128. case"second":
  129. timeType =1000;
  130. break;
  131. case"minute":
  132. timeType =1000*60;
  133. break;
  134. case"hour":
  135. timeType =1000*3600;
  136. break;
  137. case"day":
  138. timeType =1000*3600*24;
  139. break;
  140. default:
  141. break;
  142. }
  143. return parseInt((eTime.getTime() - sTime.getTime()) / parseInt(timeType));
  144. }
  145.  
  146.  
  147. function sendEmailToMe(msg) {
  148. // 函数中的代码
  149. Email.send({
  150. SecureToken:secureToken,
  151. To: to,
  152. From: from,
  153. Subject: subject,
  154. Body: `<span>该出货了,该出货了<br/>\n`+msg+`<br/></span>`
  155. }).then(
  156. message => {
  157. if (message == 'OK') {
  158. // 成功发送了邮件
  159. } else {
  160. console.error(message)
  161. }
  162. }
  163. );
  164. }
  165. })();