AutoCompleteForm

AScript!

当前为 2022-04-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @license MIT
  3. // @name AutoCompleteForm
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.1
  6. // @description AScript!
  7. // @author You
  8. // @match https://docs.google.com/forms/*
  9. // @match https://app.poap.xyz/*
  10. // @match https://gleam.io/*
  11. // @match https://discord.com/invite/*
  12. // @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. function sleep(ms = 0) {
  17. return new Promise(r => setTimeout(r, ms));
  18. }
  19.  
  20. function createBtn(name, text, top) {
  21. var btn = document.createElement('button');
  22. btn.innerText = name;
  23. btn.style.position = 'fixed';
  24. btn.style.top = `${top}px`;
  25. btn.style.left = `20%`;
  26. btn.style.width = '80px'
  27. btn.style.height = '45px'
  28. btn.addEventListener('click', () => {
  29. // 创建输入框
  30. var textarea = document.createElement('textarea');
  31. document.body.appendChild(textarea);
  32. // 隐藏此输入框
  33. textarea.style.position = 'absolute';
  34. textarea.style.clip = 'rect(0 0 0 0)';
  35. // 赋值
  36. textarea.value = text;
  37. // 选中
  38. textarea.select();
  39. // 复制
  40. document.execCommand('copy', true);
  41. console.log(`copy ${name}: ${text} success`)
  42. });
  43. return btn;
  44.  
  45. }
  46.  
  47.  
  48. const insertBtns = (accountData) => {
  49. const btnSpace = 65
  50. console.log('currentAddress', accountData.eth)
  51. let btnIndex = 1
  52. const emailBtn = createBtn("Email", accountData.email, btnIndex * btnSpace + 20);
  53. btnIndex++
  54. const discordBtn = createBtn("Discord", accountData.discord, btnIndex * btnSpace + 20);
  55. btnIndex++
  56. const ethBtn = createBtn("ETH", accountData.eth, btnIndex * btnSpace + 20);
  57. btnIndex++
  58. const solBtn = createBtn("SOL", accountData.sol, btnIndex * btnSpace + 20);
  59. btnIndex++
  60. const twitterBtn = createBtn("Twitter", accountData.twitter, btnIndex * btnSpace + 20);
  61. btnIndex++
  62. const twitterProfileBtn = createBtn("TwitterLink", accountData.twitterProfile, btnIndex * btnSpace + 20);
  63. btnIndex++
  64. var wrapper = document.body;
  65. wrapper.appendChild(emailBtn);
  66. wrapper.appendChild(discordBtn);
  67. wrapper.appendChild(discordBtn);
  68. wrapper.appendChild(ethBtn);
  69. wrapper.appendChild(solBtn);
  70. wrapper.appendChild(twitterBtn);
  71. wrapper.appendChild(twitterProfileBtn);
  72. }
  73.  
  74. const answerSnatTest01 = () => {
  75. if (document.title != '响指测验卷-01') {
  76. return
  77. }
  78. console.log("start answer snat test 01....")
  79. const spans = document.getElementsByClassName("aDTYNe snByac")
  80. for (let spanItem of spans) {
  81. const text = spanItem.textContent
  82. console.log('text', text)
  83. if (!text || !text.length) {
  84. continue
  85. }
  86.  
  87. if (
  88. text.indexOf("The end of Feb—Gift for Meta Cowboy") != -1 ||
  89. text.indexOf("股份授权证明机制") != -1 ||
  90. text.indexOf("Eat to Earn") != -1 ||
  91. text.indexOf("4个") != -1 ||
  92. text.indexOf("跟管理员撒娇") != -1 ||
  93. text.indexOf("加入未成年人防沉迷系统") != -1 ||
  94. text.indexOf("绑定金系统") != -1 ||
  95. text.indexOf("陈奕迅") != -1 ||
  96. text.indexOf("用于激励生态") != -1 ||
  97. text.indexOf("生态使用参与凭证") != -1 ||
  98. text.indexOf("进行交易兑换") != -1 ||
  99. text.indexOf("参与治理凭证") != -1 ||
  100. text.indexOf("参与治理凭证") != -1 ||
  101. text.indexOf("Volmex") != -1 ||
  102. text.indexOf("Lv8 身份的用户") != -1 ||
  103. text.indexOf("SubDAO") != -1 ||
  104. text.indexOf("StarSharks") != -1 ||
  105. text.indexOf("Good Luck Games") != -1 ||
  106. text.indexOf("10") != -1
  107. ) {
  108. spanItem.click()
  109. continue
  110. }
  111. }
  112. console.log("answer snat test 01 done")
  113. }
  114.  
  115. const autoClickGleam = async (accountData) => {
  116. const localUrl = window.document.location.href
  117. if (!localUrl || localUrl.indexOf("gleam.io") == -1) {
  118. return
  119. }
  120. console.log('gleam start')
  121. const entryList = document.getElementsByClassName("entry-method")
  122. console.log('entry', entryList.length)
  123. if (!entryList || !entryList.length) {
  124. return
  125. }
  126. for (let entry of entryList) {
  127. var observer = new MutationObserver(async function (mutations) {
  128. for (let mutation of mutations) {
  129.  
  130. const className = mutation.target.className
  131. const innerText = mutation.target.innerHTML
  132. console.log('entry', className, mutation)
  133. if (className.indexOf("completed-entry-method") != -1) {
  134. return
  135. }
  136.  
  137. if (className.indexOf("expanded") == -1) {
  138. console.log("no expanded")
  139. return
  140. }
  141. const continuBtn = mutation.target.querySelector("button")
  142. console.log('continuBtn', continuBtn)
  143. if (continuBtn) {
  144. continuBtn.click()
  145. await sleep(5000)
  146. return
  147. }
  148.  
  149. const textareaItem = mutation.target.querySelector("textarea")
  150. if (!textareaItem) {
  151. return
  152. }
  153. textareaItem.focus()
  154. if (
  155. innerText.indexOf("address") != -1 ||
  156. innerText.indexOf("wallet") != -1 ||
  157. innerText.indexOf("polygon") != -1 ||
  158. innerText.indexOf("ethereum") != -1 ||
  159. innerText.indexOf("bsc") != -1
  160. ) {
  161. document.execCommand('insertText', false, accountData.eth);
  162. } else {
  163. document.execCommand('insertText', false, accountData.email);
  164. }
  165.  
  166. await sleep(2000)
  167. const continueBtns = mutation.target.getElementsByClassName("btn btn-primary")
  168. if (continueBtns && continueBtns.length) {
  169. continueBtns[0].click()
  170. await sleep(2000)
  171. }
  172.  
  173.  
  174. }
  175. });
  176.  
  177. observer.observe(entry, {
  178. attributes: true,
  179. attributeFilter: ['class']
  180. });
  181. }
  182. console.log('gleam done')
  183. for (let entry of entryList) {
  184. const children = entry.children
  185. if (!children || !children.length) {
  186. continue
  187. }
  188. if (entry.className.indexOf("completed-entry-method") != -1) {
  189. console.log("completed entry", entry.className)
  190. continue
  191. }
  192. console.log("entry", entry.className)
  193. const innerText = entry.innerHTML
  194. if (innerText.toLowerCase().indexOf("invite") != -1 || innerText.toLowerCase().indexOf("extra entries") != -1) {
  195. console.log("invite link")
  196. continue
  197. }
  198. console.log('click entry===')
  199. children[0].click()
  200. await sleep(8000)
  201. }
  202. }
  203.  
  204. const acceptDiscord = () => {
  205. const localUrl = window.document.location.href
  206. if (!localUrl || (localUrl.indexOf("discord.com/invite/") == -1
  207. && localUrl.indexOf("discord.gg/") == -1)) {
  208. console.log('no discord')
  209. return
  210. }
  211. const btn = document.querySelector("button")
  212. if (!btn) {
  213. console.log('no button')
  214. return
  215. }
  216. btn.click()
  217. }
  218.  
  219.  
  220. (function () {
  221. 'use strict';
  222.  
  223. let windowLoaded = false
  224. let checkTimeout = 30 * 1000
  225. const checkWindowLoadingTimeoutFunc = async () => {
  226. console.log('check window timeout...')
  227. await sleep(checkTimeout)
  228. console.log('check window timeout...++++')
  229. if (!windowLoaded) {
  230. window.location.reload()
  231. }
  232. }
  233. checkWindowLoadingTimeoutFunc()
  234. window.onload = async () => {
  235. windowLoaded = true
  236. console.log('loading')
  237. await sleep(5000)
  238. let account = JSON.parse(window.localStorage.getItem("monkey_accountData"))
  239.  
  240. console.log('wait for window loading', account.eth)
  241. insertBtns(account)
  242. // answer questions
  243. answerSnatTest01()
  244. // click gleam
  245. autoClickGleam(account)
  246.  
  247. acceptDiscord()
  248.  
  249. const listWraper = document.getElementsByClassName("o3Dpx")[0]
  250. if (!listWraper) {
  251. return
  252. }
  253. const list = listWraper.children
  254. console.log(`list item len ${list.length}`)
  255. if (!list || !list.length) {
  256. return
  257. }
  258. for (let question of list) {
  259. const text = question.innerHTML.toLowerCase()
  260. const inputs = question.querySelectorAll("input")
  261. console.log('text', text.length, inputs, inputs.length)
  262. if (!inputs || inputs.length != 1) {
  263. console.log('wrong inputs', inputs)
  264. continue
  265. }
  266. const field = inputs[0]
  267. if (text.indexOf("email") != -1 || text.indexOf("邮件") != -1) {
  268. field.focus()
  269. document.execCommand('insertText', false, account.email);
  270. continue
  271. }
  272.  
  273. if (text.indexOf("wallet") != -1 || text.indexOf("address") != -1 || text.indexOf("钱包") != -1) {
  274. field.focus()
  275. document.execCommand('insertText', false, account.eth);
  276. continue
  277. }
  278.  
  279. if (text.indexOf("link") != -1 || text.indexOf("retweet") != -1) {
  280. if (text.indexOf("username") != -1) {
  281. field.focus()
  282. document.execCommand('insertText', false, `@${account.twitter}`);
  283. continue
  284. }
  285. field.focus()
  286. document.execCommand('insertText', false, account.twitterProfile);
  287. continue
  288. }
  289.  
  290. if (text.indexOf("telegram") != -1 || text.indexOf("twitter") != -1 || text.indexOf("推特") != -1) {
  291. field.focus()
  292. document.execCommand('insertText', false, `@${account.twitter}`);
  293. continue
  294. }
  295.  
  296. if (text.indexOf("discord") != -1) {
  297. field.focus()
  298. document.execCommand('insertText', false, account.discord);
  299. continue
  300. }
  301.  
  302. }
  303. }
  304. })();