AutoCompleteForm

AScript!

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

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