commit d83c6b7efe0c870f2c705294212062c4e238401d Author: Timo Hocker Date: Wed Jun 26 13:05:30 2024 +0200 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bde2dfc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/web-ext-artifacts diff --git a/README.md b/README.md new file mode 100644 index 0000000..fb18117 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Steam Game Deleter + +- Unter about:debugging#/runtime/this-firefox -> Temporäres Addon laden -> manifest.json auswählen. +- https://store.steampowered.com/account/licenses/ (mit abschließendem slash) aufrufen +- Skript sollte laufen diff --git a/icons/icon.png b/icons/icon.png new file mode 100644 index 0000000..83f126f Binary files /dev/null and b/icons/icon.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..7506a6c --- /dev/null +++ b/manifest.json @@ -0,0 +1,31 @@ +{ + "manifest_version": 2, + "name": "Steam Game Delete", + "description": "Deletes Free Steam games from library", + "version": "0.0.1", + "icons": { + "128": "icons/icon.png" + }, + "permissions": [ + "tabs", + "https://store.steampowered.com/account/licenses/" + ], + "background": { + "scripts": ["parsers.js", "background.js"] + }, + "browser_specific_settings": { + "gecko": { + "id": "steam-games-delete@scode.ovh" + } + }, + "content_scripts": [ + { + "matches": ["https://store.steampowered.com/account/licenses/"], + "js": ["site_script.js"] + } + ], + "browser_action": { + "default_icon": "icons/icon.png", + "default_title": "Steam Game Deleter" + } +} diff --git a/site_script.js b/site_script.js new file mode 100644 index 0000000..4206408 --- /dev/null +++ b/site_script.js @@ -0,0 +1,210 @@ +(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}
${errorMessage}${total}
`); + var main = jQuery(`
${headerString}
${okString}
${cancelString}
`); + + 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}
${errorMessage}${total}
`); + var main = jQuery(`
${headerString}
${okString}
${cancelString}
`); + + 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); + } + } + }) + }; +}()); \ No newline at end of file