Created
August 28, 2015 14:07
-
-
Save tarunbhardwaj/0f012c3036c4cd3c0189 to your computer and use it in GitHub Desktop.
A JS hack to grant permission of PyPi ( https://pypi.python.org/ ) packages in bulk :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For https://pypi.python.org/pypi | |
// Inject jquery before following script | |
// My quick jquery injector: | |
// javascript:var b=document.body;if(b){void(z=document.createElement('script'));void(z.type='text/javascript');void(z.src='https://code.jquery.com/jquery-1.10.2.min.js');void(b.appendChild(z));}else{} | |
var links = $("#document-navigation ul a"); | |
var test = links.each(function(index, link){ | |
var package = $(link).html(); | |
// Filter as per required condition | |
if (!(package.startsWith('fio_') || package.startsWith('openlabs_') || package.startsWith('trytond_'))) { | |
console.log("SKIP:", package); | |
return | |
} | |
$.post('/pypi', { | |
// Just paste your csrf token of PyPi, yes they don't change csrf token | |
// for long time, my guess is for a session :) | |
"CSRFToken": 'xxxxxxxxxxxxxxxxxxxx', | |
":action": 'role', | |
"user_name": 'tarunbhardwaj', // username | |
"package_name": package, | |
"role_name": 'Maintainer', // Maintainer/Owner | |
":operation": 'Add Role', | |
}).done(function () { | |
console.log("Success:", package); | |
}).fail(function (e, data) { | |
console.log("Error:", package, data); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment