Skip to content

Instantly share code, notes, and snippets.

@FreePhoenix888
Created December 2, 2022 08:13
Show Gist options
  • Save FreePhoenix888/a0fa74574d75cc21fd0a1b457889f44a to your computer and use it in GitHub Desktop.
Save FreePhoenix888/a0fa74574d75cc21fd0a1b457889f44a to your computer and use it in GitHub Desktop.
// Get your token by creating one token manually and find it in Browser Developer Tools -> Network -> GenerateApiKey -> Request
const REQUEST_VERIFICATION_TOKEN = REQUEST_VERIFICATION_TOKEN;
const packages = [
...document
.querySelector('.available-packages-container')
.querySelectorAll('input'),
].map((input) => input.parentNode.textContent.trim());
for (package of packages) {
fetch('https://www.nuget.org/account/GenerateApiKey', {
headers: {
accept: 'application/json, text/javascript, */*; q=0.01',
'accept-language': 'en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7',
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
'request-context': 'appId=cid-v1:338f6804-b1a9-4fe3-bba7-c93064e7ae7b',
'request-id': '|/QVFQ.bTGfN',
'sec-ch-ua':
'"Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Linux"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'x-requested-with': 'XMLHttpRequest',
},
referrer: 'https://www.nuget.org/account/apikeys',
referrerPolicy: 'strict-origin-when-cross-origin',
body: `description=${package}*&owner=LinksPlatform&scopes%5B%5D=package%3Apush&subjects%5B%5D=${package}*&expirationInDays=365&__RequestVerificationToken=${requestVerificationToken}`,
method: 'POST',
mode: 'cors',
credentials: 'include',
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment