Skip to content

Commit 838338e

Browse files
committed
Add some code to use cookieStoreId (it doesn't work)
1 parent fa19ed7 commit 838338e

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

scripts/background.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,16 @@ ExtensionApi.runtime.onMessage.addListener( ( request, sender, callback ) =>
5050
return false;
5151
}
5252

53+
/** @type {browser.tabs.Tab} */
54+
// @ts-ignore - cookieStoreId is only available in Firefox
55+
const firefoxTab = sender.tab;
56+
const cookieStoreId = firefoxTab?.cookieStoreId;
57+
5358
switch( request.contentScriptQuery )
5459
{
5560
case 'InvalidateCache': InvalidateCache(); callback(); return true;
56-
case 'FetchSteamUserData': FetchSteamUserData( callback ); return true;
57-
case 'FetchSteamUserFamilyData': FetchSteamUserFamilyData( callback ); return true;
61+
case 'FetchSteamUserData': FetchSteamUserData( callback, cookieStoreId ); return true;
62+
case 'FetchSteamUserFamilyData': FetchSteamUserFamilyData( callback, cookieStoreId ); return true;
5863
case 'GetApp': GetApp( request.appid, callback ); return true;
5964
case 'GetAppPrice': GetAppPrice( request, callback ); return true;
6065
case 'GetAchievementsGroups': GetAchievementsGroups( request.appid, callback ); return true;
@@ -85,8 +90,9 @@ function InvalidateCache()
8590

8691
/**
8792
* @param {(obj: {data: Record<string, any>}|{error: string, data?: Record<string, any>}) => void} callback
93+
* @param {string|undefined} cookieStoreId
8894
*/
89-
async function FetchSteamUserData( callback )
95+
async function FetchSteamUserData( callback, cookieStoreId )
9096
{
9197
if( userDataCache !== null )
9298
{
@@ -118,6 +124,9 @@ async function FetchSteamUserData( callback )
118124
// This will trigger login.steampowered.com redirect flow if user has expired cookies.
119125
Accept: 'text/html',
120126
},
127+
128+
// @ts-ignore - only available in Firefox
129+
cookieStoreId,
121130
}
122131
);
123132
const response = await responseFetch.json();
@@ -170,8 +179,9 @@ async function FetchSteamUserData( callback )
170179

171180
/**
172181
* @param {(obj: {data: Record<string, any>}|{error: string, data?: Record<string, any>}) => void} callback
182+
* @param {string|undefined} cookieStoreId
173183
*/
174-
async function FetchSteamUserFamilyData( callback )
184+
async function FetchSteamUserFamilyData( callback, cookieStoreId )
175185
{
176186
if( userFamilyDataCache !== null )
177187
{
@@ -212,6 +222,9 @@ async function FetchSteamUserFamilyData( callback )
212222
headers: {
213223
Accept: 'application/json',
214224
},
225+
226+
// @ts-ignore - only available in Firefox
227+
cookieStoreId,
215228
}
216229
);
217230
const token = await tokenResponseFetch.json();
@@ -237,7 +250,10 @@ async function FetchSteamUserFamilyData( callback )
237250
{
238251
headers: {
239252
Accept: 'application/json',
240-
}
253+
},
254+
255+
// @ts-ignore - only available in Firefox
256+
cookieStoreId,
241257
}
242258
);
243259
const response = await responseFetch.json();

0 commit comments

Comments
 (0)