Created
January 4, 2023 19:17
-
-
Save sehraf/8a6871f9f50aef758fc7dc960943e922 to your computer and use it in GitHub Desktop.
Tamper Monkey: Steam Free License Batch Remover
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Steam Free License Batch Remover | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://store.steampowered.com/account/licenses/ | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=simply-how.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// function RemoveFreeLicense( packageID, encodedPackageName ) | |
// { | |
// var dialog = ShowConfirmDialog( 'Remove License', 'Are you sure you want to remove "%s" from your account?'.replace( /%s/, atob( encodedPackageName ) ) ); | |
// dialog.done( function() { | |
// $J.ajax( | |
// { | |
// url: 'https://store.steampowered.com/account/removelicense', | |
// type: 'POST', | |
// data: | |
// { | |
// sessionid : "<your session id>", | |
// packageid : packageID | |
// }, | |
// success: function ( response ) { | |
// if ( response.success == 1 ) | |
// { | |
// top.location.reload(); | |
// } | |
// else | |
// { | |
// ShowAlertDialog( 'Error', 'An error was encountered while processing your request:' + response.success ); | |
// } | |
// } | |
// } | |
// ) | |
// } ) | |
// } | |
const url = "https://store.steampowered.com/account/removelicense"; | |
const session_id = '<your session id>' | |
function send_rq(packageID) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open("POST", url, true); | |
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); | |
xhr.onreadystatechange = function () { | |
if (xhr.readyState === 4 && xhr.status === 200) { | |
console.log(xhr.responseText); | |
} | |
}; | |
var data = []; | |
data.push(`sessionid=${encodeURIComponent(session_id)}`); | |
data.push(`packageid=${encodeURIComponent(packageID)}`); | |
const urlEncodedData = data.join('&').replace(/%20/g, '+'); | |
xhr.send(urlEncodedData); | |
} | |
var licenses = document.getElementsByClassName('free_license_remove_link'); | |
var i = 1; | |
const lim = 15; | |
console.log('found ' + licenses.length + ' free games'); | |
for (const license of licenses) { | |
for (const node of license.childNodes) { | |
if (node.nodeType != 1) { | |
continue; | |
} | |
const inner = node.href; | |
const m = /javascript:RemoveFreeLicense\(\s?(\d+),\s?\'.+\'\s?\)/g.exec(inner); | |
if (m == null) { | |
continue; | |
} | |
const packageID = m[1]; | |
setTimeout(function(){ | |
send_rq(packageID); | |
}, i*200); | |
} | |
if (i++ > lim) { | |
break; | |
} | |
} | |
d})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment