Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A JS hack to grant permission of PyPi ( https://pypi.python.org/ ) packages in bulk :)
// 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