tamper_dexscreen_getnewpair_test.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // ==UserScript==
  2. // @name DexScreen-GetNewPair
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://dexscreener.com/new-pairs*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=dexscreener.com
  9. // @grant none
  10. // ==/UserScript==
  11. // maker 降序
  12. // https://dexscreener.com/new-pairs?rankBy=pairAge&order=asc&chainIds=solana&dexIds=raydium&minLiq=2000&minAge=4&maxAge=48&min24HTxns=900&min24HBuys=800&min24HSells=800&min24HChg=100
  13. function funcDownload(content, filename) {
  14. console.log('begin download');
  15. // 创建隐藏的可下载链接
  16. var eleLink = document.createElement('a');
  17. eleLink.download = filename;
  18. eleLink.style.display = 'none';
  19. // 字符内容转变成blob地址
  20. var blob = new Blob([content]);
  21. eleLink.href = URL.createObjectURL(blob);
  22. // 触发点击
  23. document.body.appendChild(eleLink);
  24. eleLink.click();
  25. // 然后移除
  26. document.body.removeChild(eleLink);
  27. }
  28. function sleep(sleepdelay) {
  29. return new Promise((resolve, reject) => {
  30. setTimeout(() => {
  31. resolve(sleepdelay);
  32. }, sleepdelay);
  33. })
  34. }
  35. function getCurrentTime() {
  36. const zeroFill = (i) => {
  37. if (i >= 0 && i <= 9) {
  38. return "0" + i;
  39. } else {
  40. return '' + i;
  41. }
  42. }
  43. let date = new Date();//当前时间
  44. let year = date.getFullYear();
  45. let month = zeroFill(date.getMonth() + 1);//月
  46. let day = zeroFill(date.getDate());//日
  47. let hour = zeroFill(date.getHours());//时
  48. let minute = zeroFill(date.getMinutes());//分
  49. let second = zeroFill(date.getSeconds());//秒
  50. //当前时间
  51. var curTime = year + month + day + '_' + hour + minute + second;
  52. return curTime;
  53. }
  54. (async function () {
  55. await sleep(4000);
  56. console.log("enter ")
  57. var res = [];
  58. var mydivbox = document.createElement("div");
  59. //var input = document.createElement("input")
  60. var button = document.createElement("button");//创建一个按钮
  61. //mydivbox.appendChild(input);
  62. mydivbox.appendChild(button);
  63. //input.value = "350";
  64. //input.className = "tam-myinput"
  65. //input.type = "number"
  66. button.className = "tam-mybutton"
  67. button.textContent = "upstep"; //按钮内容
  68. button.style.width = "100px"; //按钮宽度
  69. button.style.height = "30px"; //按钮高度
  70. button.style.align = "center"; //文本居中
  71. button.style.color = "blue"; //按钮文字颜色
  72. button.style.background = "#e33e33"; //按钮底色
  73. button.style.border = "1px solid #e33e33"; //边框属性
  74. //button.style.borderRadius = "4px"; //按钮四个角弧度
  75. mydivbox.style.position = "fixed";
  76. mydivbox.style.top = "60px";
  77. mydivbox.style.right = "60px";
  78. // var main_div = document.getElementsByTagName("main")[0];
  79. // chakra-button__group custom-1itqpek
  80. // var parent_div = main_div.getElementsByClassName("custom-12szi09")[0];
  81. // console.log("parent_div.getElementsByClassName", parent_div.getElementsByClassName("custom-1itqpek")[0])
  82. // parent_div.insertBefore(mydivbox, parent_div.getElementsByClassName("chakra-button__group")[0]);
  83. // parent_div.appendChild(mydivbox);
  84. document.body.appendChild(mydivbox)
  85. button.addEventListener("click", clickBotton); //监听按钮点击事件
  86. function clickBotton() {
  87. console.log("entere clickBotton");
  88. res = [];
  89. let table_div = document.querySelector('.ds-dex-table.ds-dex-table-new');
  90. // let theadtitles = table_div.querySelector('.ds-dex-table-th');
  91. // let titlearr = theadtitles.innerText.trim().split(/\r?\n/);
  92. let titlearr = ["TokenIdx", 'PairAddress', 'TokenName', 'QuoteToken', 'Age', "Buys", "Sells", "Makers", 'Liquidity', 'Fdv']
  93. res.push(titlearr);
  94. let tbodytrs_arr = table_div.getElementsByTagName('a');
  95. for (let i = 0; i < tbodytrs_arr.length; i++) {
  96. let tdtexts = []
  97. let tbodytr = tbodytrs_arr[i];
  98. let tds_arr = tbodytr.querySelectorAll('.ds-table-data-cell');
  99. let token_address = tbodytr.href.trim().split('/').pop();
  100. let token_idx = tbodytr.getElementsByClassName("ds-dex-table-row-badge-pair-no")[0].innerText.trim().replace(/#/g, '');
  101. let token_name = tbodytr.getElementsByClassName('ds-dex-table-row-base-token-symbol')[0].innerText.trim();
  102. let quote_token = tbodytr.getElementsByClassName('ds-dex-table-row-quote-token-symbol')[0].innerText.trim();
  103. let pair_age = tbodytr.getElementsByClassName('ds-dex-table-row-col-pair-age')[0].innerText.trim();
  104. let pair_buys = tds_arr[3].innerText.trim().replace(/,/g, '');
  105. let pair_sells = tds_arr[4].innerText.trim().replace(/,/g, '');
  106. let pair_makers = tds_arr[6].innerText.trim().replace(/,/g, '');
  107. let pair_liquidity = tds_arr[tds_arr.length - 2].innerText.trim().replace(/[$]/, '');
  108. let pair_fdv = tds_arr[tds_arr.length - 1].innerText.trim().replace(/[$]/g, '');
  109. tdtexts = [token_idx, token_address, token_name, quote_token, pair_age, pair_buys, pair_sells, pair_makers, pair_liquidity, pair_fdv];
  110. res.push(tdtexts);
  111. }
  112. res.forEach((val, index, arr) => { arr[index] = val.join() + "\n" });
  113. let curTime = getCurrentTime();
  114. let urlpathname = window.location.pathname.slice(1).split('/').pop();
  115. urlpathname = urlpathname.replaceAll('-', "_");
  116. funcDownload(res.join(""), "sol_" + curTime + urlpathname + ".csv");
  117. }
  118. })();