GitHub Auto-Fill Form

SMNET GitHub

当前为 2024-02-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GitHub Auto-Fill Form
  3. // @version 2024-02-18
  4. // @description SMNET GitHub
  5. // @author SMNET 2311676378
  6. // @license MIT
  7. // @grant GM_xmlhttpRequest
  8. // @match https://github.com/github-copilot/signup/billing?*
  9. // @namespace https://greasyfork.org/users/1218336
  10. // ==/UserScript==
  11.  
  12. function fillForm(data) {
  13. let firstName = data.address.Full_Name.split(" ")[0];
  14. let lastName = data.address.Full_Name.split(" ")[1] || firstName;
  15. document.getElementById('account_screening_profile_first_name').value = firstName;
  16. document.getElementById('account_screening_profile_last_name').value = lastName;
  17.  
  18. document.getElementById('account_screening_profile_address1').value = data.address.Address;
  19. document.getElementById('account_screening_profile_city').value = data.address.City;
  20. document.getElementById('account_screening_profile_region').value = data.address.State_Full;
  21.  
  22. let countrySelect = document.getElementById('account_screening_profile_country_code');
  23. for(let i=0; i<countrySelect.options.length; i++){
  24. if(countrySelect.options[i].innerText === 'United States of America'){
  25. countrySelect.value = countrySelect.options[i].value;
  26. break;
  27. }
  28. }
  29. document.getElementById('account_screening_profile_postal_code').value = data.address.Zip_Code;
  30. }
  31.  
  32. window.onload = () => {
  33. GM_xmlhttpRequest({
  34. method: 'POST',
  35. url: 'https://www.meiguodizhi.com/api/v1/dz',
  36. headers: {
  37. 'Content-Type': 'application/json',
  38. },
  39. data: JSON.stringify({
  40. "city": "",
  41. "path": "/",
  42. "method": "refresh"
  43. }),
  44. onload: (response) => {
  45. var data = JSON.parse(response.responseText);
  46. fillForm(data);
  47. },
  48. onerror: (error) => {
  49. console.error('Error during request:', error);
  50. }
  51. });
  52. };