Skip to content

Commit 7702b5e

Browse files
committed
Add script to dump string literals with all urls
1 parent 0ddda20 commit 7702b5e

File tree

5 files changed

+205
-2
lines changed

5 files changed

+205
-2
lines changed

.eslintrc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ env:
44
extends: eslint:recommended
55
parserOptions:
66
ecmaVersion: latest
7+
sourceType: module

API/JavascriptUrls.txt

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
${CHAT_BASE_URL}broadcast/addbroadcastwebrtccandidate
2+
${CHAT_BASE_URL}broadcast/ajaxupdatechannelmod
3+
${CHAT_BASE_URL}broadcast/ajaxupdateusermute
4+
${CHAT_BASE_URL}broadcast/getbroadcastinfo/
5+
${CHAT_BASE_URL}broadcast/getbroadcastwebrtccandidates
6+
${CHAT_BASE_URL}broadcast/getchatinfo
7+
${CHAT_BASE_URL}broadcast/setbroadcastwebrtcanswer
8+
${COMMUNITY_BASE_URL}actions/FileUploader/
9+
${COMMUNITY_BASE_URL}actions/GameAvatars/?json=1&l=${LANGUAGE}
10+
${COMMUNITY_BASE_URL}actions/selectPreviousAvatar
11+
${COMMUNITY_BASE_URL}app/${unAppID}
12+
${COMMUNITY_BASE_URL}app/${}
13+
${COMMUNITY_BASE_URL}broadcast/watch/${steamid64}
14+
${COMMUNITY_BASE_URL}chat/invite/${}
15+
${COMMUNITY_BASE_URL}economy/image/${}/512x512
16+
${COMMUNITY_BASE_URL}economy/profilebackground/items/${appid}/${item_image_large}?size=320x200
17+
${COMMUNITY_BASE_URL}games/${_ ? _ : _}/partnerevents/
18+
${COMMUNITY_BASE_URL}gid/${}
19+
${COMMUNITY_BASE_URL}gid/${}/membersManage
20+
${COMMUNITY_BASE_URL}id/${m_strCustomURL}/
21+
${COMMUNITY_BASE_URL}market
22+
${COMMUNITY_BASE_URL}market/listings/${}/${}
23+
${COMMUNITY_BASE_URL}ogg/${}/selectAvatar
24+
${COMMUNITY_BASE_URL}profiles/${STEAM_ID}/wishlist
25+
${COMMUNITY_BASE_URL}profiles/${steamid}/
26+
${COMMUNITY_BASE_URL}profiles/${}/tradeoffers/sent/#tradeofferid_${}
27+
${COMMUNITY_BASE_URL}sale/ajaxgetcategoriesbytag
28+
${COMMUNITY_BASE_URL}tradeoffer/new/?partner=${}
29+
${COMMUNITY_BASE_URL}tradeoffer/new/?partner=${}&for_items[]=${}_${}_${}
30+
${COMMUNITY_BASE_URL}tradeoffer/new/?partner=${}&token=${}
31+
${HELP_BASE_URL}
32+
${HELP_BASE_URL}wizard/HelpWithLogin?redir=${}
33+
${HELP_BASE_URL}wizard/HelpWithLoginInfo?lost=8&issueid=402
34+
${LOGIN_BASE_URL}jwt/finalizelogin
35+
${PARTNER_BASE_URL}admin/editdiscountevent/${id}
36+
${PARTNER_BASE_URL}admin/game/edit/${}?activetab=tab_graphicalassets
37+
${PARTNER_BASE_URL}admin/store/suggestpackage
38+
${PARTNER_BASE_URL}apps/builddetails/${appid}/${}
39+
${PARTNER_BASE_URL}apps/suggestapps
40+
${PARTNER_BASE_URL}bundles/suggestbundle
41+
${PARTNER_BASE_URL}doc/${}
42+
${PARTNER_BASE_URL}promotion/dailydeals/ajaxsearcharchives
43+
${PARTNER_BASE_URL}store/packagelanding/${}
44+
${STORE_BASE_URL}${}/${id}${_ ? _ : ""}
45+
${STORE_BASE_URL}${}/${id}${_ ? `?${}` : ""}
46+
${STORE_BASE_URL}${}/${}
47+
${STORE_BASE_URL}${}/${}${_ ? _ : ""}
48+
${STORE_BASE_URL}${}/${}${_ ? `?${}` : ""}
49+
${STORE_BASE_URL}${}/download/${}/${}/${GID}?${}
50+
${STORE_BASE_URL}/events_admin/ajaxhidefromsteamchina
51+
${STORE_BASE_URL}account/preferences/#store_broadcast_settings
52+
${STORE_BASE_URL}actions/ajaxgetstorecategories
53+
${STORE_BASE_URL}actions/ajaxgetstoretags
54+
${STORE_BASE_URL}api/appdetails?appids=${}&cc=${}&language=${LANGUAGE}&filters=basic,price_overview,developers,screenshots,movies,release_date,content_descriptors&client=${IN_CLIENT}
55+
${STORE_BASE_URL}app/${appid}
56+
${STORE_BASE_URL}app/${appid}/#app_reviews_hash
57+
${STORE_BASE_URL}app/${id}
58+
${STORE_BASE_URL}app/${m_strAppId}
59+
${STORE_BASE_URL}app/${}
60+
${STORE_BASE_URL}broadcast/ajaxgetappinfoforcap
61+
${STORE_BASE_URL}cart
62+
${STORE_BASE_URL}cart/addtocart
63+
${STORE_BASE_URL}cart/ajaxredeemtokensforcartdiscount
64+
${STORE_BASE_URL}contenthub/ajaxgetcontenthubs
65+
${STORE_BASE_URL}contenthub/ajaxgetcontenthubsections
66+
${STORE_BASE_URL}curator/${}${_ ? _ : ""}
67+
${STORE_BASE_URL}curator/${}${_ ? `?${}` : ""}
68+
${STORE_BASE_URL}curator/0/ajaxsearchcurators
69+
${STORE_BASE_URL}events_promotion_admin/ajaxitemsuggest
70+
${STORE_BASE_URL}join/
71+
${STORE_BASE_URL}labs/ajaxgetappsimilarities?appidtarget=${}&${}
72+
${STORE_BASE_URL}labs/ajaxgetappsimilarities?appidtarget=${}&appid[]=${}
73+
${STORE_BASE_URL}labs/ajaxgetappvectors?${}&model=${similarity_model}
74+
${STORE_BASE_URL}labs/ajaxgetmostsimilarappstovector?${}&model=${similarity_model}
75+
${STORE_BASE_URL}labs/ajaxgetsimilarapps?appid=${}
76+
${STORE_BASE_URL}labs/ajaxgetsimilarapps?appid=${}&model=${similarity_model}
77+
${STORE_BASE_URL}labs/ajaxgetsimilaritymodelnames
78+
${STORE_BASE_URL}news/${}/view/${announcement_gid}
79+
${STORE_BASE_URL}news/app/${}/view/${}
80+
${STORE_BASE_URL}points/
81+
${STORE_BASE_URL}points/heroimage?appid=${}
82+
${STORE_BASE_URL}points/howitworks
83+
${STORE_BASE_URL}points/shop/c/chateffects
84+
${STORE_BASE_URL}points/shop/c/emoticons
85+
${STORE_BASE_URL}points/shop/c/stickers
86+
${STORE_BASE_URL}search/suggest
87+
${STORE_BASE_URL}tags/${}/${name}
88+
${WEBAPI_BASE_URL}IBroadcastService/MuteBroadcastChatUser/v0001/?access_token=${m_webApiToken}
89+
${WEBAPI_BASE_URL}IBroadcastService/PostChatMessage/v0001?access_token=${m_webApiToken}
90+
${WEBAPI_BASE_URL}IBroadcastService/RemoveUserChatText/v0001/?access_token=${m_webApiToken}
91+
${WEBAPI_BASE_URL}IBroadcastService/UpdateChatMessageFlair/v0001/?access_token=${m_webApiToken}
92+
${WEBAPI_BASE_URL}ISteamUserOAuth/GetUserSummaries/v2/

dump_javascript_urls.mjs

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import path from "path";
2+
import fs from "fs";
3+
import { parse, latestEcmaVersion } from "espree";
4+
import { traverse } from "estraverse";
5+
6+
const allStrings = new Set();
7+
const files = await GetListOfFilesToParse("./.support/original_js/");
8+
9+
for (const file of files) {
10+
try {
11+
const code = fs.readFileSync(file);
12+
const ast = parse(code, { ecmaVersion: latestEcmaVersion });
13+
14+
traverse(ast, {
15+
enter: function(node) {
16+
if (node.type === "TemplateLiteral") {
17+
let found = false;
18+
19+
for (const expr of node.expressions) {
20+
if (
21+
expr.type === "MemberExpression" &&
22+
expr.property.type === "Identifier" &&
23+
expr.property.name.endsWith("_BASE_URL")
24+
) {
25+
found = true;
26+
break;
27+
}
28+
}
29+
30+
if (!found) {
31+
return;
32+
}
33+
34+
allStrings.add(ConstructLiteral(node));
35+
36+
this.skip();
37+
}
38+
},
39+
});
40+
} catch (e) {
41+
console.error(`Unable to parse "${path.basename(file)}": ${e}`);
42+
continue;
43+
}
44+
}
45+
46+
const strings = [...allStrings.values()].sort().join("\n") + "\n";
47+
48+
fs.writeFileSync("API/JavascriptUrls.txt", strings);
49+
50+
function GetListOfFilesToParse(dirName) {
51+
return fs.promises
52+
.readdir(dirName)
53+
.then((files) =>
54+
files.filter((fileName) => fileName.endsWith("js")).map((fileName) => path.join(dirName, fileName))
55+
);
56+
}
57+
58+
function IsSafeName(name) {
59+
return name.length > 2 || name.toUpperCase() === "ID";
60+
}
61+
62+
function ConstructLiteral(parent) {
63+
const nodes = [...(parent.expressions || []), ...parent.quasis].sort((a, b) => a.start - b.start);
64+
const str = [];
65+
66+
for (const node of nodes) {
67+
if (node.type === "TemplateElement") {
68+
str.push(node.value.raw);
69+
} else if (
70+
node.type === "MemberExpression" &&
71+
node.property.type === "Identifier" &&
72+
IsSafeName(node.property.name)
73+
) {
74+
str.push(`\${${node.property.name}}`);
75+
} else if (node.type === "Identifier" && IsSafeName(node.name)) {
76+
str.push(`\${${node.name}}`);
77+
} else if (node.type === "ConditionalExpression") {
78+
str.push("${_ ? ");
79+
80+
if (node.consequent.type === "Literal") {
81+
str.push(node.consequent.raw);
82+
} else if (node.consequent.type === "TemplateLiteral") {
83+
str.push(`\`${ConstructLiteral(node.consequent)}\``);
84+
} else {
85+
str.push("_");
86+
}
87+
88+
str.push(" : ");
89+
90+
if (node.alternate.type === "Literal") {
91+
str.push(node.alternate.raw);
92+
} else if (node.alternate.type === "TemplateLiteral") {
93+
str.push(`\`${ConstructLiteral(node.alternate)}\``);
94+
} else {
95+
str.push("_");
96+
}
97+
98+
str.push("}");
99+
} else if (node.type === "TemplateLiteral") {
100+
str.push(`\`${ConstructLiteral(node)}\``);
101+
} else {
102+
str.push("${}");
103+
}
104+
}
105+
106+
return str.join("");
107+
}

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"private": true,
33
"name": "steamtracking",
44
"scripts": {
5-
"eslint": "eslint ./protobufdumper.js",
6-
"format": "prettier --write --use-tabs --print-width 120 ./protobufdumper.js",
5+
"eslint": "eslint ./protobufdumper.js ./dump_javascript_urls.mjs",
6+
"format": "prettier --write --use-tabs --print-width 120 ./protobufdumper.js ./dump_javascript_urls.mjs",
77
"prettier": "prettier --write"
88
},
99
"dependencies": {
10+
"espree": "^9.3.1",
11+
"estraverse": "^5.3.0",
1012
"prettier": "^2.2.1"
1113
},
1214
"devDependencies": {

update.php

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public function __construct( string $Option )
123123
$this->Log( '{lightblue}Dumping web protobufs' );
124124

125125
system( 'node protobufdumper.js' );
126+
system( 'node dump_javascript_urls.mjs' );
126127
system(
127128
'grep \'([A-Z_]+)BASE_URL\+"[0-9a-z\/]+"\' --no-filename --only-matching --extended-regexp --recursive ' .
128129
escapeshellarg( __DIR__ . '/.support/original_js/' ) .

0 commit comments

Comments
 (0)