GitHub Auto-Fill Form

SMNET GitHub

Ajankohdalta 18.2.2024. Katso uusin versio.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name     GitHub Auto-Fill Form
// @version      2024-02-18
// @description  SMNET GitHub
// @author       SMNET 2311676378
// @license MIT
// @grant    GM_xmlhttpRequest
// @match  https://github.com/github-copilot/signup/billing?*
// @namespace https://greasyfork.org/users/1218336
// ==/UserScript==

function fillForm(data) {
    let firstName = data.address.Full_Name.split(" ")[0];
    let lastName = data.address.Full_Name.split(" ")[1] || firstName;
    document.getElementById('account_screening_profile_first_name').value = firstName;
    document.getElementById('account_screening_profile_last_name').value = lastName;

    document.getElementById('account_screening_profile_address1').value = data.address.Address;
    document.getElementById('account_screening_profile_city').value = data.address.City;
    document.getElementById('account_screening_profile_region').value = data.address.State_Full;

    let countrySelect = document.getElementById('account_screening_profile_country_code');
    for(let i=0; i<countrySelect.options.length; i++){
        if(countrySelect.options[i].innerText === 'United States of America'){
            countrySelect.value = countrySelect.options[i].value;
            break;
        }
    }
    document.getElementById('account_screening_profile_postal_code').value = data.address.Zip_Code;
}

window.onload = () => {
    GM_xmlhttpRequest({
        method: 'POST',
        url: 'https://www.meiguodizhi.com/api/v1/dz',
        headers: {
            'Content-Type': 'application/json',
        },
        data: JSON.stringify({
            "city": "",
            "path": "/",
            "method": "refresh"
        }),
        onload: (response) => {
            var data = JSON.parse(response.responseText);
            fillForm(data);
        },
        onerror: (error) => {
            console.error('Error during request:', error);
        }
    });
};