AutoCompleteForm

AScript!

目前為 2022-04-14 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name AutoCompleteForm
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.13
  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. 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 if (innerText.indexOf("discord") != -1) {
  163. document.execCommand('insertText', false, accountData.discord);
  164. } else if (innerText.indexOf("twitter") != -1) {
  165. document.execCommand('insertText', false, accountData.twitter);
  166. } else if (innerText.indexOf("color of the hat") != -1) {
  167. document.execCommand('insertText', false, "blue");
  168. } else {
  169. document.execCommand('insertText', false, accountData.email);
  170. }
  171.  
  172. await sleep(2000)
  173. const continueBtns = mutation.target.getElementsByClassName("btn btn-primary")
  174. if (continueBtns && continueBtns.length) {
  175. continueBtns[0].click()
  176. await sleep(2000)
  177. }
  178.  
  179.  
  180. }
  181. });
  182.  
  183. observer.observe(entry, {
  184. attributes: true,
  185. attributeFilter: ['class']
  186. });
  187. }
  188. console.log('gleam done')
  189. for (let entry of entryList) {
  190. const children = entry.children
  191. if (!children || !children.length) {
  192. continue
  193. }
  194. if (entry.className.indexOf("completed-entry-method") != -1) {
  195. console.log("completed entry", entry.className)
  196. continue
  197. }
  198. console.log("entry", entry.className)
  199. const innerText = entry.innerHTML
  200. if (innerText.toLowerCase().indexOf("invite") != -1 || innerText.toLowerCase().indexOf("extra entries") != -1) {
  201. console.log("invite link")
  202. continue
  203. }
  204. console.log('click entry===')
  205. children[0].click()
  206. await sleep(8000)
  207. }
  208. }
  209.  
  210. const acceptDiscord = () => {
  211. const localUrl = window.document.location.href
  212. if (!localUrl || (localUrl.indexOf("discord.com/invite/") == -1
  213. && localUrl.indexOf("discord.gg/") == -1)) {
  214. console.log('no discord')
  215. return
  216. }
  217. const btn = document.querySelector("button")
  218. if (!btn) {
  219. console.log('no button')
  220. return
  221. }
  222. btn.click()
  223.  
  224. let catchWin = window
  225.  
  226. setTimeout(() => {
  227. if (catchWin.document.body.innerHTML.indexOf("Continue to Discord") != -1) {
  228. catchWin.location.href = "https://google.com"
  229. }
  230.  
  231.  
  232. }, 5000)
  233. }
  234.  
  235.  
  236. (function () {
  237. 'use strict';
  238.  
  239. let windowLoaded = false
  240. let checkTimeout = 30 * 1000
  241. const checkWindowLoadingTimeoutFunc = async () => {
  242. console.log('check window timeout...')
  243. await sleep(checkTimeout)
  244. console.log('check window timeout...++++')
  245. if (!windowLoaded) {
  246. window.location.reload()
  247. }
  248. }
  249. checkWindowLoadingTimeoutFunc()
  250. window.onload = async () => {
  251. windowLoaded = true
  252. console.log('loading')
  253. await sleep(5000)
  254. let account = JSON.parse(window.localStorage.getItem("monkey_accountData"))
  255. console.log('current account', account.eth)
  256. insertBtns(account)
  257. // answer questions
  258. answerSnatTest01()
  259. // click gleam
  260. autoClickGleam(account)
  261.  
  262. acceptDiscord()
  263.  
  264. const listWraper = document.getElementsByClassName("o3Dpx")[0]
  265. if (!listWraper) {
  266. return
  267. }
  268. const list = listWraper.children
  269. console.log(`list item len ${list.length}`)
  270. if (!list || !list.length) {
  271. return
  272. }
  273. for (let question of list) {
  274. const text = question.innerHTML.toLowerCase()
  275. let inputs = question.querySelectorAll("input")
  276. console.log('text', text.length, inputs, inputs.length)
  277. if (!inputs || inputs.length != 1) {
  278. inputs = question.querySelectorAll("textarea")
  279. if (!inputs || inputs.length != 1) {
  280. console.log('wrong inputs', inputs)
  281. continue
  282. }
  283. }
  284. const field = inputs[0]
  285. if (text.indexOf("email") != -1 || text.indexOf("邮件") != -1) {
  286. field.focus()
  287. document.execCommand('insertText', false, account.email);
  288. continue
  289. }
  290.  
  291. if (text.indexOf("wallet") != -1 || text.indexOf("address") != -1 || text.indexOf("钱包") != -1) {
  292. field.focus()
  293. document.execCommand('insertText', false, account.eth);
  294. continue
  295. }
  296.  
  297. if (text.indexOf("link") != -1 || text.indexOf("retweet") != -1) {
  298. if (text.indexOf("username") != -1) {
  299. field.focus()
  300. document.execCommand('insertText', false, `@${account.twitter}`);
  301. continue
  302. }
  303. field.focus()
  304. document.execCommand('insertText', false, account.twitterProfile);
  305. continue
  306. }
  307.  
  308. if (text.indexOf("telegram") != -1 || text.indexOf("twitter") != -1 || text.indexOf("推特") != -1 || text.indexOf("nickname") != -1) {
  309. field.focus()
  310. document.execCommand('insertText', false, `@${account.twitter}`);
  311. continue
  312. }
  313.  
  314. if (text.indexOf("discord") != -1) {
  315. field.focus()
  316. document.execCommand('insertText', false, account.discord);
  317. continue
  318. }
  319.  
  320. }
  321. }
  322. })();