Skip to content

Commit

Permalink
Add toggling private an app
Browse files Browse the repository at this point in the history
  • Loading branch information
Lifeismana committed Oct 17, 2024
1 parent 91cedb8 commit c1c2606
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ ExtensionApi.runtime.onMessage.addListener( ( request, sender, callback ) =>
case 'GetApp': GetApp( request.appid, callback ); return true;
case 'GetAppPrice': GetAppPrice( request, callback ); return true;
case 'GetAchievementsGroups': GetAchievementsGroups( request.appid, callback ); return true;
case 'SetAppPrivate': SetAppPrivate( request.appids, request.private, callback ); return true;
case 'StoreWishlistAdd': StoreWishlistAdd( request.appid, callback ); return true;
case 'StoreWishlistRemove': StoreWishlistRemove( request.appid, callback ); return true;
case 'StoreFollow': StoreFollow( request.appid, callback ); return true;
Expand Down Expand Up @@ -484,6 +485,27 @@ function GetAchievementsGroups( appid, callback )
.catch( ( error ) => callback( { success: false, error: error.message } ) );
}

/**
* @param {Array<Number>} appids
* @param {Boolean} privateState
* @param {Function} callback
*/
// ? Api supports setting multiple apps at once (Are they even using that feature?), do we really need that?
async function SetAppPrivate( appids, privateState, callback )
{
const token = await GetStoreToken();
const paramsSetPrivate = new URLSearchParams();
paramsSetPrivate.set( 'access_token', token );
appids.forEach( ( appid, index ) =>
{
paramsSetPrivate.set( `appids[${index}]`, appid );
} );
paramsSetPrivate.set( 'private', privateState );
const responseFetch = await fetch(
`https://api.steampowered.com/IAccountPrivateAppsService/ToggleAppPrivacy/v1/?${paramsSetPrivate.toString()}`
);
}

/**
* @return {Promise<String>}
*/
Expand Down

0 comments on commit c1c2606

Please sign in to comment.