AutoCompleteForm

AScript!

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

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