(function() {
const delay = 500;
const licensesUrl = `https://store.steampowered.com/account/licenses/`;
const removeLicensesUrl = `https://store.steampowered.com/account/removelicense`;
const warningString = 'Code cannot be executed here. You will be automatically redirected to the correct page. Please run this code on Steam\'s account page details: store.steampowered.com/account/licenses';
const analysisHeader = 'Analyzing...';
const analysisText = 'Please wait until analysis is complete.';
const headerString = 'Games removing';
const okString = 'Remove';
const cancelString = 'Cancel';
const mainInfo = 'You have game(s) can be removed.
Enter the number of games you want to remove.';
const errorMessage = 'Enter number from 0 to ';
const removingHeader = 'In Progress...';
const removingText = 'Don\'t forget to say thanks if you like the script ;) Removed:';
const noGamesToRemoveMessage = 'There are no games available for removing.'
const rateLimitedMessage = 'You have been rate limited, try again later!'
const errorMessage2 = 'An error was encountered while processing your request:'
if (location.href != (licensesUrl)) {
alert(warningString);
window.location = (licensesUrl);
return;
}
var freeLicensePackages = [];
var modal = ShowBlockingWaitDialog(analysisHeader, analysisText);
jQuery('.free_license_remove_link a').each(function(i, el) {
var matched = decodeURI(el.href).match(/\d{4,}/);
if (matched !== null) {
freeLicensePackages.push(+matched);
}
});
modal.Dismiss();
var total = freeLicensePackages.length;
if (total == 0) {
alert(noGamesToRemoveMessage);
return;
}
var enteredNumber = total;
var desc = jQuery(`
${mainInfo}
`);
var main = jQuery(``);
jQuery('body').append(main);
jQuery('#cancelButton').on('click', function (event) {
jQuery('.newmodal').remove();
jQuery('.newmodal_background').remove();
});
jQuery('#mainDiv').html(desc);
jQuery('#numberGames').text(total);
jQuery('#games_number').val(total);
jQuery('#games_number').on('change', function (event) {
var input = jQuery(this);
var value = +input.val();
if (!Number.isInteger(value) || value > total || value <= 0) {
input.css('border-color', 'red');
input.next('span').show();
jQuery('#okButton').hide();
}
else {
enteredNumber = value;
input.css('border-color', '');
input.next('span').hide();
jQuery('#okButton').show();
}
});
var removed = 0;
jQuery('#okButton').on('click', function (event) {
jQuery('.newmodal').remove();
jQuery('.newmodal_background').remove();
proceed();
});
const proceed = () => {
if (modal) {
modal.Dismiss();
}
if (removed >= enteredNumber) {
location.reload();
}
else {
modal = ShowBlockingWaitDialog(removingHeader, `${removingText} ${removed}/${enteredNumber}.`);
deleteFunc(removed++);
}
};
const deleteFunc = (index) => {
jQuery.ajax({url: removeLicensesUrl,
type: 'POST',
data: { packageid: freeLicensePackages[index], sessionid: g_sessionID },
success: function ( response ) {
if ( response.success == 1 ) {
setTimeout(() => proceed(), delay)
}
else {
modal.Dismiss();
if (response.success = 84)
ShowAlertDialog( 'Error', rateLimitedMessage + ' Error: ' + response.success);
else
ShowAlertDialog( 'Error', errorMessage2 + ' ' + response.success);
... (5 lines left)
Collapse
message.txt
5 KB
(function() {
const delay = 500;
const licensesUrl = `https://store.steampowered.com/account/licenses/`;
const removeLicensesUrl = `https://store.steampowered.com/account/removelicense`;
const warningString = 'Code cannot be executed here. You will be automatically redirected to the correct page. Please run this code on Steam\'s account page details: store.steampowered.com/account/licenses';
const analysisHeader = 'Analyzing...';
const analysisText = 'Please wait until analysis is complete.';
const headerString = 'Games removing';
const okString = 'Remove';
const cancelString = 'Cancel';
const mainInfo = 'You have game(s) can be removed.
Enter the number of games you want to remove.';
const errorMessage = 'Enter number from 0 to ';
const removingHeader = 'In Progress...';
const removingText = 'Don\'t forget to say thanks if you like the script ;) Removed:';
const noGamesToRemoveMessage = 'There are no games available for removing.'
const rateLimitedMessage = 'You have been rate limited, try again later!'
const errorMessage2 = 'An error was encountered while processing your request:'
if (location.href != (licensesUrl)) {
alert(warningString);
window.location = (licensesUrl);
return;
}
var freeLicensePackages = [];
var modal = ShowBlockingWaitDialog(analysisHeader, analysisText);
jQuery('.free_license_remove_link a').each(function(i, el) {
var matched = decodeURI(el.href).match(/\d{4,}/);
if (matched !== null) {
freeLicensePackages.push(+matched);
}
});
modal.Dismiss();
var total = freeLicensePackages.length;
if (total == 0) {
alert(noGamesToRemoveMessage);
return;
}
var enteredNumber = total;
var desc = jQuery(`${mainInfo}
`);
var main = jQuery(``);
jQuery('body').append(main);
jQuery('#cancelButton').on('click', function (event) {
jQuery('.newmodal').remove();
jQuery('.newmodal_background').remove();
});
jQuery('#mainDiv').html(desc);
jQuery('#numberGames').text(total);
jQuery('#games_number').val(total);
jQuery('#games_number').on('change', function (event) {
var input = jQuery(this);
var value = +input.val();
if (!Number.isInteger(value) || value > total || value <= 0) {
input.css('border-color', 'red');
input.next('span').show();
jQuery('#okButton').hide();
}
else {
enteredNumber = value;
input.css('border-color', '');
input.next('span').hide();
jQuery('#okButton').show();
}
});
var removed = 0;
jQuery('#okButton').on('click', function (event) {
jQuery('.newmodal').remove();
jQuery('.newmodal_background').remove();
proceed();
});
const proceed = () => {
if (modal) {
modal.Dismiss();
}
if (removed >= enteredNumber) {
location.reload();
}
else {
modal = ShowBlockingWaitDialog(removingHeader, `${removingText} ${removed}/${enteredNumber}.`);
deleteFunc(removed++);
}
};
const deleteFunc = (index) => {
jQuery.ajax({url: removeLicensesUrl,
type: 'POST',
data: { packageid: freeLicensePackages[index], sessionid: g_sessionID },
success: function ( response ) {
if ( response.success == 1 ) {
setTimeout(() => proceed(), delay)
}
else {
modal.Dismiss();
if (response.success = 84)
ShowAlertDialog( 'Error', rateLimitedMessage + ' Error: ' + response.success);
else
ShowAlertDialog( 'Error', errorMessage2 + ' ' + response.success);
}
}
})
};
}());