AutoCompleteForm

AScript!

  1. // ==UserScript==
  2. // @name AutoCompleteForm
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.14.12
  5. // @description AScript!
  6. // @author You
  7. // @match https://docs.google.com/forms/*
  8. // @match https://app.poap.xyz/*
  9. // @match https://gleam.io/*
  10. // @match https://discord.com/invite/*
  11. // @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
  12. // @grant none
  13. // @license MIT
  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. if (!accountData) {
  50. return
  51. }
  52. const btnSpace = 65
  53. console.log('currentAddress', accountData.eth)
  54. let btnIndex = 1
  55. const emailBtn = createBtn("Email", accountData.email, btnIndex * btnSpace + 20);
  56. btnIndex++
  57. const discordBtn = createBtn("Discord", accountData.discord, btnIndex * btnSpace + 20);
  58. btnIndex++
  59. const ethBtn = createBtn("ETH", accountData.eth, btnIndex * btnSpace + 20);
  60. btnIndex++
  61. const solBtn = createBtn("SOL", accountData.sol, btnIndex * btnSpace + 20);
  62. btnIndex++
  63. const twitterBtn = createBtn("Twitter", accountData.twitter, btnIndex * btnSpace + 20);
  64. btnIndex++
  65. const twitterProfileBtn = createBtn("TwitterLink", accountData.twitterProfile, btnIndex * btnSpace + 20);
  66. btnIndex++
  67. var wrapper = document.body;
  68. wrapper.appendChild(emailBtn);
  69. wrapper.appendChild(discordBtn);
  70. wrapper.appendChild(discordBtn);
  71. wrapper.appendChild(ethBtn);
  72. wrapper.appendChild(solBtn);
  73. wrapper.appendChild(twitterBtn);
  74. wrapper.appendChild(twitterProfileBtn);
  75. }
  76.  
  77. const answerSnatTest01 = () => {
  78. if (document.title != '响指测验卷-01') {
  79. return
  80. }
  81. console.log("start answer snat test 01....")
  82. const spans = document.getElementsByClassName("aDTYNe snByac")
  83. for (let spanItem of spans) {
  84. const text = spanItem.textContent
  85. console.log('text', text)
  86. if (!text || !text.length) {
  87. continue
  88. }
  89.  
  90. if (
  91. text.indexOf("The end of Feb—Gift for Meta Cowboy") != -1 ||
  92. text.indexOf("股份授权证明机制") != -1 ||
  93. text.indexOf("Eat to Earn") != -1 ||
  94. text.indexOf("4个") != -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("进行交易兑换") != -1 ||
  102. text.indexOf("参与治理凭证") != -1 ||
  103. text.indexOf("参与治理凭证") != -1 ||
  104. text.indexOf("Volmex") != -1 ||
  105. text.indexOf("Lv8 身份的用户") != -1 ||
  106. text.indexOf("SubDAO") != -1 ||
  107. text.indexOf("StarSharks") != -1 ||
  108. text.indexOf("Good Luck Games") != -1 ||
  109. text.indexOf("10") != -1
  110. ) {
  111. spanItem.click()
  112. continue
  113. }
  114. }
  115. console.log("answer snat test 01 done")
  116. }
  117.  
  118.  
  119. const answerCryptoKudasaiJP = () => {
  120. if (document.title.indexOf("CryptoKudasaiJP") == -1) {
  121. return
  122. }
  123. console.log("start answer CryptoKudasaiJP....")
  124. const spans = document.getElementsByClassName("aDTYNe snByac")
  125. for (let spanItem of spans) {
  126. const text = spanItem.textContent
  127. console.log('text', text)
  128. if (!text || !text.length) {
  129. continue
  130. }
  131.  
  132. if (
  133. text.indexOf("はい") != -1
  134. ) {
  135. spanItem.click()
  136. continue
  137. }
  138. }
  139. console.log("answer snat test 01 done")
  140. }
  141.  
  142. const answerMoleHack = () => {
  143. if (document.title.indexOf('MoleHack: NFT 2.0 Finale Quiz') == -1) {
  144. return
  145. }
  146. console.log("start answer MoleHack....")
  147. const spans = document.getElementsByClassName("aDTYNe snByac")
  148. for (let spanItem of spans) {
  149. const text = spanItem.textContent
  150. console.log('text', text)
  151. if (!text || !text.length) {
  152. continue
  153. }
  154.  
  155. if (
  156. text.indexOf("NFT 2.0") != -1 ||
  157. text.indexOf("Project Galaxy") != -1
  158. ) {
  159. spanItem.click()
  160. continue
  161. }
  162. }
  163. console.log("answer snat test 01 done")
  164. }
  165.  
  166. const handleGleamEntry = async (entry, accountData) => {
  167. const innerText = entry.innerHTML.toLowerCase()
  168. const continuBtn = entry.querySelector("button")
  169. console.log('continuBtn', continuBtn)
  170. if (continuBtn) {
  171. continuBtn.click()
  172. await sleep(5000)
  173. return
  174. }
  175.  
  176. const textareaItem = entry.querySelector("textarea")
  177. if (!textareaItem) {
  178. console.log('no textarea')
  179. return
  180. }
  181. textareaItem.focus()
  182. if (
  183. innerText.indexOf("address") != -1 ||
  184. innerText.indexOf("wallet") != -1 ||
  185. innerText.indexOf("polygon") != -1 ||
  186. innerText.indexOf("ethereum") != -1 ||
  187. innerText.indexOf("bsc") != -1
  188. ) {
  189. document.execCommand('insertText', false, accountData.eth);
  190. } else if (innerText.indexOf("discord") != -1) {
  191. document.execCommand('insertText', false, accountData.discord);
  192. } else if (innerText.indexOf("speakers were featured") != -1) {
  193. document.execCommand('insertText', false, "8");
  194. } else if (innerText.indexOf("twitter") != -1) {
  195. document.execCommand('insertText', false, `@${accountData.twitter}`);
  196. } else if (innerText.indexOf("color of the hat") != -1) {
  197. document.execCommand('insertText', false, "blue");
  198. } else {
  199. document.execCommand('insertText', false, accountData.email);
  200. }
  201.  
  202. await sleep(2000)
  203. const continueBtns = entry.getElementsByClassName("btn btn-primary")
  204. if (continueBtns && continueBtns.length) {
  205. continueBtns[0].click()
  206. await sleep(2000)
  207. }
  208. }
  209.  
  210. class ActionPromise {
  211. constructor(_id, _timeout) {
  212. this.id = _id
  213. this.timeout = _timeout || 10000
  214. console.log(`new actionPromise id ${this.id}, timeout ${this.timeout}`)
  215. let entryResolve
  216. const entryPromise = new Promise((resolve, reject) => {
  217. entryResolve = resolve
  218. })
  219. const entryWaitfunc = async () => {
  220. return entryPromise
  221. }
  222. this.entryResolve = entryResolve
  223. this.entryPromise = entryPromise
  224. this.entryWaitfunc = entryWaitfunc
  225. }
  226. async wait() {
  227. let catchThis = this
  228. setTimeout(() => {
  229. if (catchThis.done) {
  230. return
  231. }
  232. console.log(`action ${catchThis.id} timeout`)
  233. catchThis.done = true
  234. catchThis.entryResolve()
  235. }, this.timeout)
  236. await this.entryWaitfunc()
  237. }
  238. resolve() {
  239. this.done = true
  240. this.entryResolve()
  241. }
  242.  
  243. }
  244.  
  245. const preFillWallet = async (accountData) => {
  246. if (!accountData) {
  247. return
  248. }
  249. const inputWraps = document.getElementsByClassName("input boolean form-group additional-checkbox")
  250. if (!inputWraps || !inputWraps.length) {
  251. console.log('no inputWraps')
  252. return
  253. }
  254. for (let item of inputWraps) {
  255. const inputItem = item.querySelector("input")
  256. console.log("click input", inputItem)
  257. inputItem.click()
  258. }
  259.  
  260. const walletInputs = document.getElementsByName("bep20_wallet_address")
  261. if (!walletInputs || !walletInputs.length) {
  262. return
  263. }
  264. console.log('walletInputs', walletInputs[0], accountData.eth)
  265. await sleep(6000)
  266. walletInputs[0].focus()
  267.  
  268. document.execCommand('insertText', false, accountData.eth);
  269.  
  270. }
  271.  
  272. const autoClickGleam = async (accountData) => {
  273. if (!accountData) {
  274. return
  275. }
  276. const localUrl = window.document.location.href
  277. if (!localUrl || localUrl.indexOf("gleam.io") == -1) {
  278. return
  279. }
  280. if (document.body.innerHTML.indexOf("agree to the following") != -1) {
  281. console.log("pre fill wallet")
  282. await preFillWallet(accountData)
  283. await sleep(15000)
  284. }
  285. console.log('gleam loading start')
  286. const entryList = document.getElementsByClassName("entry-method")
  287. console.log('all entry count', entryList.length)
  288. if (!entryList || !entryList.length) {
  289. return
  290. }
  291. let waitGroup = {}
  292. for (let entry of entryList) {
  293.  
  294. waitGroup[entry.id] = new ActionPromise(entry.id, 5000)
  295. console.log("add entry wait group", entry.id)
  296. var observer = new MutationObserver(async function (mutations) {
  297. for (let mutation of mutations) {
  298.  
  299. const className = mutation.target.className
  300. console.log('entry class onChange', className, mutation.target.id, mutation)
  301. if (className.indexOf("completed-entry-method") != -1) {
  302. const ap = waitGroup[entry.id]
  303. if (!ap.done) {
  304. ap.resolve()
  305. }
  306. return
  307. }
  308.  
  309. if (className.indexOf("expanded") == -1) {
  310. console.log("no expanded")
  311. return
  312. }
  313.  
  314. await handleGleamEntry(mutation.target, accountData)
  315. }
  316. });
  317.  
  318. observer.observe(entry, {
  319. attributes: true,
  320. attributeFilter: ['class']
  321. });
  322. }
  323.  
  324. console.log('gleam add watch done')
  325. for (let i = 0; i < entryList.length; i++) {
  326. const entry = entryList[i]
  327. const children = entry.children
  328. if (!children || !children.length) {
  329. continue
  330. }
  331. console.log(`entry ${i}, class ${entry.className}`)
  332.  
  333. if (entry.className.indexOf("completed-entry-method") != -1) {
  334. console.log("completed entry", entry.className)
  335. continue
  336. }
  337.  
  338. if (entry.className.indexOf("expanded") != -1) {
  339. console.log("expanded entry", i)
  340. await handleGleamEntry(entry, accountData)
  341. await sleep(10000)
  342. continue
  343. }
  344.  
  345. }
  346. for (let i = 0; i < entryList.length; i++) {
  347. const entry = entryList[i]
  348. const children = entry.children
  349. if (!children || !children.length) {
  350. continue
  351. }
  352. if (entry.className.indexOf("completed-entry-method") != -1) {
  353. console.log("completed entry", i, entry.className)
  354. continue
  355. }
  356.  
  357. if (entry.className.indexOf("expanded") != -1) {
  358. console.log("expanded entry second loop", i)
  359. // await handleGleamEntry(entry, accountData)
  360. continue
  361. }
  362. const innerText = entry.innerHTML.toLowerCase()
  363. if (innerText.indexOf("extra entries") != -1) {
  364. console.log("extra entries")
  365. continue
  366. }
  367. if (innerText.indexOf("secret code") != -1) {
  368. console.log("skip secret code now")
  369. continue
  370. }
  371. console.log(`click entry ${i}, ${entry.id}`)
  372. children[0].click()
  373. console.log("waiting...")
  374. await waitGroup[entry.id].wait()
  375. console.log("waiting... done")
  376.  
  377. }
  378. }
  379.  
  380. const acceptDiscord = () => {
  381. const localUrl = window.document.location.href
  382. if (!localUrl || (localUrl.indexOf("discord.com/invite/") == -1
  383. && localUrl.indexOf("discord.gg/") == -1)) {
  384. console.log('it is not a discord invite link')
  385. return
  386. }
  387. const btn = document.querySelector("button")
  388. if (!btn) {
  389. console.log('discord invite link has no button')
  390. return
  391. }
  392. btn.click()
  393.  
  394. let catchWin = window
  395.  
  396. setTimeout(() => {
  397. if (catchWin.document.body.innerHTML.indexOf("Continue to Discord") != -1) {
  398. catchWin.location.href = "https://google.com"
  399. }
  400.  
  401.  
  402. }, 5000)
  403. }
  404.  
  405.  
  406. (function () {
  407. 'use strict';
  408.  
  409. if (window.location.href.indexOf("google") != -1 && window.location.href.indexOf("formResponse") != -1) {
  410. console.log("google response form")
  411. return
  412. }
  413.  
  414. let windowLoaded = false
  415. let checkTimeout = 5 * 1000
  416. const checkWindowLoadingTimeoutFunc = async () => {
  417. console.log('check window timeout...')
  418. await sleep(checkTimeout)
  419. console.log('check window timeout...++++')
  420. if (!windowLoaded) {
  421. window.location.reload()
  422. }
  423. }
  424. checkWindowLoadingTimeoutFunc()
  425. window.onload = async () => {
  426. windowLoaded = true
  427. console.log('loading')
  428. await sleep(2000)
  429. let account = undefined
  430.  
  431. if (window.localStorage) {
  432. account = JSON.parse(window.localStorage.getItem("monkey_accountData"))
  433. }
  434. console.log('current account', account && account.eth)
  435. insertBtns(account)
  436. // answer questions
  437. answerSnatTest01()
  438. // answer molehack
  439. answerMoleHack()
  440. answerCryptoKudasaiJP()
  441. // click gleam
  442. autoClickGleam(account)
  443.  
  444. acceptDiscord()
  445.  
  446. const listWraper = document.getElementsByClassName("o3Dpx")[0]
  447. if (!listWraper) {
  448. return
  449. }
  450. const list = listWraper.children
  451. console.log(`list item len ${list.length}`)
  452. if (!list || !list.length) {
  453. return
  454. }
  455. for (let question of list) {
  456. const text = question.innerHTML.toLowerCase()
  457. let inputs = question.querySelectorAll("input")
  458. console.log('text', text.length, inputs, inputs.length)
  459. if (!inputs || inputs.length != 1) {
  460. inputs = question.querySelectorAll("textarea")
  461. if (!inputs || inputs.length != 1) {
  462. console.log('wrong inputs', inputs)
  463. continue
  464. }
  465. }
  466. const field = inputs[0]
  467. if (text.indexOf("email") != -1 || text.indexOf("邮件") != -1) {
  468. field.focus()
  469. document.execCommand('insertText', false, account.email);
  470. continue
  471. }
  472.  
  473.  
  474. if (text.indexOf('solana address') != -1) {
  475. field.focus()
  476. document.execCommand('insertText', false, account.sol);
  477. continue
  478. }
  479.  
  480. if (text.indexOf("wallet") != -1 || text.indexOf("address") != -1 || text.indexOf("钱包") != -1) {
  481. field.focus()
  482. document.execCommand('insertText', false, account.eth);
  483. continue
  484. }
  485.  
  486. if (text.indexOf("link") != -1 || text.indexOf("retweet") != -1) {
  487. if (text.indexOf("username") != -1) {
  488. field.focus()
  489. document.execCommand('insertText', false, `@${account.twitter}`);
  490. continue
  491. }
  492. field.focus()
  493. document.execCommand('insertText', false, account.twitterProfile);
  494. continue
  495. }
  496.  
  497. if (text.indexOf("telegram") != -1 || text.indexOf("twitter") != -1 || text.indexOf("推特") != -1 || text.indexOf("nickname") != -1) {
  498. field.focus()
  499. document.execCommand('insertText', false, `@${account.twitter}`);
  500. continue
  501. }
  502.  
  503. if (text.indexOf("discord") != -1) {
  504. field.focus()
  505. document.execCommand('insertText', false, account.discord);
  506. continue
  507. }
  508. if (text.indexOf("ideas") != -1 || text.indexOf("感想") != -1) {
  509. field.focus()
  510. document.execCommand('insertText', false, 'no');
  511. continue
  512. }
  513.  
  514.  
  515. }
  516. }
  517. })();

QingJ © 2025

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