Skip to content

Commit

Permalink
functionality fix
Browse files Browse the repository at this point in the history
config now checks if JS is valid and is on disk to prevent misinforming the user about JS injection.
  • Loading branch information
ShadowMonster99 committed Jan 17, 2024
1 parent e04d676 commit d34321a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
12 changes: 8 additions & 4 deletions src/core/injector/event_handler.cpp
Expand Up @@ -423,7 +423,14 @@ class client : public std::enable_shared_from_this<client>

// if the hooked file is a css file, we want to add the colors structure.
if (isCss) {
responseBody = base64_encode(std::format("{}\n\n/*\nTHE FOLLOWING WAS INJECTED BY MILLENNIUM\n*/\n\n{}\n\n/*\nBEGIN COLOR INSERTION\n*/\n{}\n/*\nEND COLORS\n*/\n/*\nEND INJECTION\n*/", base64_decode(m_socket_resp["result"]["body"]), g_fileResponse, colors == "[NoColors]" ? std::string() : colors));
responseBody = base64_encode(std::format(
"{}\n\n/*\nTHE FOLLOWING WAS INJECTED BY MILLENNIUM\n*/"
"\n\n{}\n\n"
"/*\nBEGIN COLOR INSERTION\n*/"
"\n{}\n"
"/*\nEND COLORS\n*/\n"
"/*\nEND INJECTION\n*/",
base64_decode(m_socket_resp["result"]["body"]), g_fileResponse, colors == "[NoColors]" ? std::string() : colors));
}
else {
responseBody = base64_encode(std::format("{}\n\n/*\nTHE FOLLOWING WAS INJECTED BY MILLENNIUM\n*/\n\n{}\n\n/*\nEND INJECTION\n*/", base64_decode(m_socket_resp["result"]["body"]), g_fileResponse));
Expand Down Expand Up @@ -507,7 +514,6 @@ class client : public std::enable_shared_from_this<client>
}

// parse if statement is array object or single

std::vector<nlohmann::basic_json<>> statements;

if (patch["Statement"].is_object())
Expand Down Expand Up @@ -587,8 +593,6 @@ class client : public std::enable_shared_from_this<client>
}
}



return returnVal.empty() ? std::vector<statementReturn>{ {true} } : returnVal;
}

Expand Down
2 changes: 0 additions & 2 deletions src/millennium.vcxproj
Expand Up @@ -256,7 +256,6 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="auto-updater.hpp" />
<ClInclude Include="core\injector\event_handler.hpp" />
<ClInclude Include="core\injector\startup\welcome_modal.hpp" />
<ClInclude Include="core\ipc\ipc_main.hpp" />
Expand Down Expand Up @@ -291,7 +290,6 @@
<ClInclude Include="utils\cout\logger.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="auto-updater.cpp" />
<ClCompile Include="core\injector\event_handler.cpp" />
<ClCompile Include="core\injector\startup\welcome_modal.cpp" />
<ClCompile Include="core\ipc\ipc_main.cpp" />
Expand Down
17 changes: 13 additions & 4 deletions src/utils/config/config.cpp
Expand Up @@ -448,13 +448,22 @@ const nlohmann::json themeConfig::getThemeData(bool raw) noexcept
}

bool hasJavaScriptPatch = std::any_of(jsonBuffer["Patches"].begin(), jsonBuffer["Patches"].end(),
[](const nlohmann::json& patch) {
return patch.contains("TargetJs");
[&](const nlohmann::json& patch) {
if (patch.contains("TargetJs")) {

const std::string fileName = patch["TargetJs"].get<std::string>();
std::string filePath = std::format("{}/{}/{}", m_themesPath, ACTIVE_ITEM, fileName);

if (std::filesystem::exists(filePath)) {
return true;
}
}
return false;
});

if (hasJavaScriptPatch && Settings::Get<bool>("allow-javascript") == false && !Settings::Get<bool>("prompted-js")) {
if (hasJavaScriptPatch && Settings::Get<bool>("allow-javascript") == false) {
int result = MsgBox(
"The selected theme may be using JavaScript to enhance your Steam experience.\n"
"The selected theme is using JavaScript to enhance your Steam experience.\n"
"You have JavaScript disabled in Millennium settings, therefore, the selected skin may not function properly.\n\n"
"Enable JavaScript ONLY IF you trust the developer, have manually reviewed the code, or it's an official theme.\n\n"
"Would you like to enable JavaScript execution?",
Expand Down

0 comments on commit d34321a

Please sign in to comment.