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 για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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