AutoCompleteForm

AScript!

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

  1. // ==UserScript==
  2. // @name AutoCompleteForm
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.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. 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. let catchWin = window
  219.  
  220. setTimeout(() => {
  221. if (catchWin.document.body.innerHTML.indexOf("Continue to Discord") != -1) {
  222. catchWin.location.href = "https://google.com"
  223. }
  224.  
  225.  
  226. }, 5000)
  227. }
  228.  
  229.  
  230. (function () {
  231. 'use strict';
  232.  
  233. let windowLoaded = false
  234. let checkTimeout = 30 * 1000
  235. const checkWindowLoadingTimeoutFunc = async () => {
  236. console.log('check window timeout...')
  237. await sleep(checkTimeout)
  238. console.log('check window timeout...++++')
  239. if (!windowLoaded) {
  240. window.location.reload()
  241. }
  242. }
  243. checkWindowLoadingTimeoutFunc()
  244. window.onload = async () => {
  245. windowLoaded = true
  246. console.log('loading')
  247. await sleep(5000)
  248. let account = JSON.parse(window.localStorage.getItem("monkey_accountData"))
  249. console.log('current account', account.eth)
  250. insertBtns(account)
  251. // answer questions
  252. answerSnatTest01()
  253. // click gleam
  254. autoClickGleam(account)
  255.  
  256. acceptDiscord()
  257.  
  258. const listWraper = document.getElementsByClassName("o3Dpx")[0]
  259. if (!listWraper) {
  260. return
  261. }
  262. const list = listWraper.children
  263. console.log(`list item len ${list.length}`)
  264. if (!list || !list.length) {
  265. return
  266. }
  267. for (let question of list) {
  268. const text = question.innerHTML.toLowerCase()
  269. let inputs = question.querySelectorAll("input")
  270. console.log('text', text.length, inputs, inputs.length)
  271. if (!inputs || inputs.length != 1) {
  272. inputs = question.querySelectorAll("textarea")
  273. if (!inputs || inputs.length != 1) {
  274. console.log('wrong inputs', inputs)
  275. continue
  276. }
  277. }
  278. const field = inputs[0]
  279. if (text.indexOf("email") != -1 || text.indexOf("邮件") != -1) {
  280. field.focus()
  281. document.execCommand('insertText', false, account.email);
  282. continue
  283. }
  284.  
  285. if (text.indexOf("wallet") != -1 || text.indexOf("address") != -1 || text.indexOf("钱包") != -1) {
  286. field.focus()
  287. document.execCommand('insertText', false, account.eth);
  288. continue
  289. }
  290.  
  291. if (text.indexOf("link") != -1 || text.indexOf("retweet") != -1) {
  292. if (text.indexOf("username") != -1) {
  293. field.focus()
  294. document.execCommand('insertText', false, `@${account.twitter}`);
  295. continue
  296. }
  297. field.focus()
  298. document.execCommand('insertText', false, account.twitterProfile);
  299. continue
  300. }
  301.  
  302. if (text.indexOf("telegram") != -1 || text.indexOf("twitter") != -1 || text.indexOf("推特") != -1 || text.indexOf("nickname") != -1) {
  303. field.focus()
  304. document.execCommand('insertText', false, `@${account.twitter}`);
  305. continue
  306. }
  307.  
  308. if (text.indexOf("discord") != -1) {
  309. field.focus()
  310. document.execCommand('insertText', false, account.discord);
  311. continue
  312. }
  313.  
  314. }
  315. }
  316. })();