Telegram App Creator

自动化创建 Telegram 应用程序

  1. // ==UserScript==
  2. // @name Telegram App Creator
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description 自动化创建 Telegram 应用程序
  6. // @author HgTRojan
  7. // @match https://my.telegram.org/apps
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 配置变量
  16. const appTitle = 'Your App Title';
  17. const appShortname = 'YourShortName';
  18. const appUrl = 'https://yourapp.example.com';
  19. const appDescription = 'Your app description';
  20. const repetitions = 3000; // 重复次数
  21.  
  22. // 等待函数
  23. const waitForSelector = (selector, timeout = 5000) => {
  24. return new Promise((resolve, reject) => {
  25. const interval = 100;
  26. let elapsed = 0;
  27. const checkExist = setInterval(() => {
  28. if (document.querySelector(selector)) {
  29. clearInterval(checkExist);
  30. resolve();
  31. }
  32. elapsed += interval;
  33. if (elapsed >= timeout) {
  34. clearInterval(checkExist);
  35. reject(`Timeout waiting for selector: ${selector}`);
  36. }
  37. }, interval);
  38. });
  39. };
  40.  
  41. // 表单填写和提交函数
  42. const createApp = async () => {
  43. try {
  44. await waitForSelector('#app_title');
  45. document.querySelector('#app_title').click();
  46. document.querySelector('#app_title').value = appTitle;
  47.  
  48. await waitForSelector('#app_shortname');
  49. document.querySelector('#app_shortname').click();
  50. document.querySelector('#app_shortname').value = appShortname;
  51.  
  52. await waitForSelector('#app_url');
  53. document.querySelector('#app_url').click();
  54. document.querySelector('#app_url').value = appUrl;
  55.  
  56. await waitForSelector('div:nth-of-type(4) div:nth-of-type(6)');
  57. document.querySelector('div:nth-of-type(4) div:nth-of-type(6)').click();
  58.  
  59. await waitForSelector('div:nth-of-type(6) > label');
  60. document.querySelector('div:nth-of-type(6) > label').click();
  61.  
  62. await waitForSelector('#app_desc');
  63. document.querySelector('#app_desc').click();
  64. document.querySelector('#app_desc').value = appDescription;
  65.  
  66. await waitForSelector('#app_save_btn');
  67. document.querySelector('#app_save_btn').click();
  68.  
  69. console.log('Application created successfully.');
  70. } catch (error) {
  71. console.error('Error creating application:', error);
  72. }
  73. };
  74.  
  75. // 主函数
  76. const main = async () => {
  77. for (let i = 0; i < repetitions; i++) {
  78. console.log(`Creating application ${i + 1}...`);
  79. await createApp();
  80. }
  81. };
  82.  
  83. // 执行主函数
  84. main();
  85. })();

QingJ © 2025

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