// ==UserScript==
// @name Autodecline/autoapprove
// @include *translation.steampowered.com/user_activity.php*
// @version 1
// @require http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==
jQuery.noConflict();
//console.log('good syntax');
var userid = location.search;
function perform(button, action) {
var first = jQuery('li:contains("...ARE PENDING")').next();
if (!first.length)
first = jQuery('li').first();
var suggestions = first.nextUntil('li:contains("...WERE APPROVED") + *').add(first);
var total = suggestions.length;
var done = 0;
button.text(done + '/' + total + ' SUGGESTIONS ' + action + 'D');
suggestions.each(function() {
var text = jQuery('a', this).text().split(': ')[1].split(' >> ');
var key = text[0];
//console.log(key);
text = text[1].split('/');
var filename = text.pop().trim();
var branch = text.join('/');
var language = filename.split('.')[0].split('_')[1];
filename = filename.replace(language, 'english');
var link = 'https://translation.steampowered.com/suggestions.php?lang=' + language + '&branch=' + branch + '&filename=' + filename + '&token_key=' + escape(key);
jQuery.get(link, function(data) {
var sugs = jQuery('.suggestion_signature', jQuery(data)).has('a[href="user_activity.php' + userid + '"]');
sugs.each(function() {
var url = jQuery('input[value="' + action + '"]', this).attr('onclick');
if (url) {
jQuery.get(url.split("'")[1], function() {
if (++done == total)
location.reload(true);
button.text(done + '/' + total + ' SUGGESTIONS ' + action + 'D');
});
}
});
});
});
}
var abuse = jQuery('span:contains("REPORT ABUSE BY THIS USER")');
var approve = jQuery('APPROVE ALL');
var decline = jQuery('DECLINE ALL');
abuse.after(approve);
abuse.after('
');
abuse.after(decline);
abuse.after('
');
decline.click(function() { perform(jQuery(this), 'DECLINE'); return false; });
approve.click(function() { perform(jQuery(this), 'APPROVE'); return false; });