Skip to content

Instantly share code, notes, and snippets.

@pataiadam
Last active May 4, 2021 12:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pataiadam/9e127e8d88f776e43a899754bf335cca to your computer and use it in GitHub Desktop.
Save pataiadam/9e127e8d88f776e43a899754bf335cca to your computer and use it in GitHub Desktop.
gurushot vote refresher bookmarklet
/**
Converted Bookmarklet (by https://mrcoles.com/bookmarklet):
javascript:(function()%7B(async%20function()%20%7B%24('.expcucc').remove()%3B%24('.c-challenges-item__exposure__meter__arrow').each(function(i)%20%7B%24(this).parent().parent().prepend('%3Cdiv%20class%3D%22expcucc%22%20style%3D%22position%3A%20absolute%3B%20right%3A%200%22%3EFetching...%3C%2Fdiv%3E')%3B%7D)%3B%24('.c-challenges-item__votes__total').each(function()%20%7B%24(this).text('...')%3B%7D)%3B%24('.c-challenges-item__photos__body').each(function(i)%20%7B%24(this).children().each(function(j)%20%7B%24(this).children('.c-challenges-item__photos__photo__votes').text('...')%3B%7D)%3B%7D)%3Bconst%20resp%20%3D%20await%20(await%20fetch('https%3A%2F%2Fgurushots.com%2Frest%2Fget_member_joined_active_challenges'%2C%20%7Bheaders%3A%20%7B'x-api-version'%3A%207%2C'x-env'%3A%20'WEB'%2C'x-requested-with'%3A%20'XMLHttpRequest'%2C'x-token'%3A%20((name)%20%3D%3E%20%7Bvar%20value%20%3D%20%22%3B%20%22%20%2B%20document.cookie%3Bvar%20parts%20%3D%20value.split(%22%3B%20%22%20%2B%20name%20%2B%20%22%3D%22)%3Bif%20(parts.length%20%3D%3D%202)%20return%20parts.pop().split(%22%3B%22).shift()%3B%7D)('gs_t')%7D%2Cmethod%3A%20'POST'%2Ccredentials%3A%20'same-origin'%7D)).json()%3B%24('.expcucc').remove()%3B%24('.c-challenges-item__votes__total').each(function(i)%20%7B%24(this).text(resp.challenges%5Bi%5D.member.ranking.total.votes)%3B%7D)%3B%24('.c-challenges-item__photos__body').each(function(i)%20%7B%24(this).children().each(function(j)%20%7B%24(this).children('.c-challenges-item__photos__photo__votes').text(resp.challenges%5Bi%5D.member.ranking.entries%5Bj%5D.votes)%3B%7D)%3B%7D)%3B%24('.c-challenges-item__exposure__meter__arrow').each(function(i)%20%7Blet%20p%20%3D%20%20(resp.challenges%5Bi%5D.member.ranking.exposure.exposure_factor).toFixed(1)%3B%24(this).parent().parent().prepend('%3Cdiv%20class%3D%22expcucc%22%20style%3D%22position%3A%20absolute%3B%20right%3A%200%22%3E'%20%2Bp%20%2B%20'%25%3C%2Fdiv%3E')%3B%24(this).parent().parent().prepend('%3Cdiv%20class%3D%22expcucc%22%20style%3D%22position%3A%20absolute%3B%20left%3A%200%22%3E'%20%2B%20Math.ceil((100-p)%2F1.5)%20%2B%20'%20votes%20needed%3C%2Fdiv%3E')%3B%7D)%3B%7D)()%7D)()
*/
/*
$('.gs-btn--blue').click();$('.modal-vote__photo__vote').slice(0,prompt("Enter num", "10")).click()
*/
(async function() {
$('.expcucc').remove();
$('.c-challenges-item__exposure__meter__arrow').each(function(i) {
$(this).parent().parent().prepend('<div class="expcucc" style="position: absolute; right: 0">Fetching...</div>');
});
$('.c-challenges-item__votes__total').each(function() {
$(this).text('...');
});
$('.c-challenges-item__photos__body').each(function(i) {
$(this).children().each(function(j) {
$(this).children('.c-challenges-item__photos__photo__votes').text('...');
});
});
const resp = await (await fetch('https://gurushots.com/rest/get_member_joined_active_challenges', {
headers: {
'x-api-version': 7,
'x-env': 'WEB',
'x-requested-with': 'XMLHttpRequest',
'x-token': ((name) => {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
})('gs_t')
},
method: 'POST',
credentials: 'same-origin'
})).json();
$('.expcucc').remove();
$('.c-challenges-item__votes__total').each(function(i) {
$(this).text(resp.challenges[i].member.ranking.total.votes);
});
$('.c-challenges-item__photos__body').each(function(i) {
$(this).children().each(function(j) {
$(this).children('.c-challenges-item__photos__photo__votes').text(resp.challenges[i].member.ranking.entries[j].votes);
});
});
$('.c-challenges-item__exposure__meter__arrow').each(function(i) {
let p = (resp.challenges[i].member.ranking.exposure.exposure_factor).toFixed(1);
$(this).parent().parent().prepend('<div class="expcucc" style="position: absolute; right: 0">' +p + '%</div>');
$(this).parent().parent().prepend('<div class="expcucc" style="position: absolute; left: 0">' + Math.ceil((100-p)/1.5) + ' votes needed</div>');
});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment