GitHub Auto-Fill Form

SMNET GitHub

От 18.02.2024. Виж последната версия.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

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

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==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);
        }
    });
};