Skip to content

Instantly share code, notes, and snippets.

@omkelderman
Last active May 20, 2020 09:44
Show Gist options
  • Save omkelderman/1d288b6720e606663c9d470120e2f5f3 to your computer and use it in GitHub Desktop.
Save omkelderman/1d288b6720e606663c9d470120e2f5f3 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name osu! forum multi voter
// @namespace https://github.com/omkelderman/
// @version 1.0
// @description Promote feature request on the osu! forum multiple times in one go
// @author Olle Kelderman
// @match https://osu.ppy.sh/community/forums/topics/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function doMultiVote(votesLeft) {
if(votesLeft <= 0) return;
let voteButton = $('[data-url$="/vote-feature"]');
if(voteButton.prop('disabled')) {
// button disabled, try again half a second later
console.log('[osu! forum auto voter] ['+votesLeft+' votes left] vote button disabled, waiting 500ms', voteButton);
setTimeout(function() {
doMultiVote(votesLeft);
}, 500);
return;
}
// vote button enabled, hit it and continue for 1 second, but now with votesLeft decremented
console.log('[osu! forum auto voter] ['+votesLeft+' votes left] clicking vote! Waiting 5 seconds for next vote');
voteButton.click();
var newVotesLeft = votesLeft - 1;
if(newVotesLeft == 0) {
console.log('[osu! forum auto voter] Done!');
alert('Done!');
return;
}
setTimeout(function() {
doMultiVote(newVotesLeft);
}, 5000);
}
let voteButton = $('[data-url$="/vote-feature"]');
if(voteButton.length == 1) {
// ok lets add our own button
voteButton.parent().append($('<button>').addClass('btn-osu-big btn-osu-big--forum-secondary').text('Promote multiple times').click(function() {
let voteCount = parseInt(prompt('vote how many times?'), 10);
if(!voteCount || voteCount <= 1) {
alert('please fill in a number bigger then or equal to 2');
return;
}
doMultiVote(voteCount);
}));
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment