From 84c3d9b5b6846b66462f23160ff23e565fbd002b Mon Sep 17 00:00:00 2001 From: oneflux Date: Mon, 21 Apr 2025 16:15:33 -0700 Subject: [PATCH] remove mouse automation functionality --- .../chrome/overrides/appstrings.properties | 22 +- additions/camoucfg/MouseTrajectories.hpp | 236 ------------------ additions/camoucfg/moz.build | 3 +- patches/chromeutil.patch | 1 - 4 files changed, 12 insertions(+), 250 deletions(-) delete mode 100644 additions/camoucfg/MouseTrajectories.hpp diff --git a/additions/browser/locales/en-US/chrome/overrides/appstrings.properties b/additions/browser/locales/en-US/chrome/overrides/appstrings.properties index 8650cf9..1a399d4 100644 --- a/additions/browser/locales/en-US/chrome/overrides/appstrings.properties +++ b/additions/browser/locales/en-US/chrome/overrides/appstrings.properties @@ -3,25 +3,25 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. malformedURI2=Please check that the URL is correct and try again. -fileNotFound=Camoufox can’t find the file at %S. +fileNotFound=Omegafox can’t find the file at %S. fileAccessDenied=The file at %S is not readable. dnsNotFound2=We can’t connect to the server at %S. -unknownProtocolFound=Camoufox doesn’t know how to open this address, because one of the following protocols (%S) isn’t associated with any program or is not allowed in this context. -connectionFailure=Camoufox can’t establish a connection to the server at %S. +unknownProtocolFound=Omegafox doesn’t know how to open this address, because one of the following protocols (%S) isn’t associated with any program or is not allowed in this context. +connectionFailure=Omegafox can’t establish a connection to the server at %S. netInterrupt=The connection to %S was interrupted while the page was loading. netTimeout=The server at %S is taking too long to respond. -redirectLoop=Camoufox has detected that the server is redirecting the request for this address in a way that will never complete. +redirectLoop=Omegafox has detected that the server is redirecting the request for this address in a way that will never complete. ## LOCALIZATION NOTE (confirmRepostPrompt): In this item, don’t translate "%S" confirmRepostPrompt=To display this page, %S must send information that will repeat any action (such as a search or order confirmation) that was performed earlier. resendButton.label=Resend -unknownSocketType=Camoufox doesn’t know how to communicate with the server. +unknownSocketType=Omegafox doesn’t know how to communicate with the server. netReset=The connection to the server was reset while the page was loading. notCached=This document is no longer available. -netOffline=Camoufox is currently in offline mode and can’t browse the Web. +netOffline=Omegafox is currently in offline mode and can’t browse the Web. isprinting=The document cannot change while Printing or in Print Preview. -deniedPortAccess=This address uses a network port which is normally used for purposes other than Web browsing. Camoufox has canceled the request for your protection. -proxyResolveFailure=Camoufox is configured to use a proxy server that can’t be found. -proxyConnectFailure=Camoufox is configured to use a proxy server that is refusing connections. +deniedPortAccess=This address uses a network port which is normally used for purposes other than Web browsing. Omegafox has canceled the request for your protection. +proxyResolveFailure=Omegafox is configured to use a proxy server that can’t be found. +proxyConnectFailure=Omegafox is configured to use a proxy server that is refusing connections. contentEncodingError=The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression. unsafeContentType=The page you are trying to view cannot be shown because it is contained in a file type that may not be safe to open. Please contact the website owners to inform them of this problem. externalProtocolTitle=External Protocol Request @@ -38,7 +38,7 @@ cspBlocked=This page has a content security policy that prevents it from being l xfoBlocked=This page has an X-Frame-Options policy that prevents it from being loaded in this context. corruptedContentErrorv2=The site at %S has experienced a network protocol violation that cannot be repaired. ## LOCALIZATION NOTE (sslv3Used) - Do not translate "%S". -sslv3Used=Camoufox cannot guarantee the safety of your data on %S because it uses SSLv3, a broken security protocol. +sslv3Used=Omegafox cannot guarantee the safety of your data on %S because it uses SSLv3, a broken security protocol. inadequateSecurityError=The website tried to negotiate an inadequate level of security. blockedByPolicy=Your organization has blocked access to this page or website. -networkProtocolError=Camoufox has experienced a network protocol violation that cannot be repaired. +networkProtocolError=Omegafox has experienced a network protocol violation that cannot be repaired. diff --git a/additions/camoucfg/MouseTrajectories.hpp b/additions/camoucfg/MouseTrajectories.hpp deleted file mode 100644 index 10b6a10..0000000 --- a/additions/camoucfg/MouseTrajectories.hpp +++ /dev/null @@ -1,236 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "MaskConfig.hpp" - -/** - * Human-like mouse movement generator. Ported from: - * https://github.com/riflosnake/HumanCursor/blob/main/humancursor/utilities/human_curve_generator.py - * Modified to use a more human-like easing function. - */ - -class BezierCalculator { - public: - static long long factorial(int n) { - if (n < 0) return -1; // Indicate error - long long result = 1; - for (int i = 2; i <= n; i++) result *= i; - return result; - } - - static double binomial(int n, int k) { - return static_cast(factorial(n)) / - (factorial(k) * factorial(n - k)); - } - - static double bernsteinPolynomialPoint(double x, int i, int n) { - return binomial(n, i) * std::pow(x, i) * std::pow(1 - x, n - i); - } - - static std::vector bernsteinPolynomial( - const std::vector>& points, double t) { - int n = static_cast(points.size()) - 1; - double x = 0.0; - double y = 0.0; - for (int i = 0; i <= n; i++) { - double bern = bernsteinPolynomialPoint(t, i, n); - x += points[i].first * bern; - y += points[i].second * bern; - } - return {x, y}; - } - - static std::vector> calculatePointsInCurve( - int nPoints, const std::vector>& points) { - std::vector> curvePoints; - for (int i = 0; i < nPoints; i++) { - double t = static_cast(i) / (nPoints - 1); - curvePoints.push_back(bernsteinPolynomial(points, t)); - } - return curvePoints; - } -}; - -class HumanizeMouseTrajectory { - public: - HumanizeMouseTrajectory(const std::pair& fromPoint, - const std::pair& toPoint) - : fromPoint(fromPoint), toPoint(toPoint) { - generateCurve(); - } - - std::vector getPoints() const { - std::vector flatPoints; - flatPoints.reserve(points.size() * 2); - - for (const auto& point : points) { - flatPoints.push_back(static_cast(std::round(point[0]))); - flatPoints.push_back(static_cast(std::round(point[1]))); - } - - return flatPoints; - } - - private: - std::pair fromPoint; - std::pair toPoint; - std::vector> points; - - void generateCurve() { - double leftBoundary = std::min(fromPoint.first, toPoint.first) - 80.0; - double rightBoundary = std::max(fromPoint.first, toPoint.first) + 80.0; - double downBoundary = std::min(fromPoint.second, toPoint.second) - 80.0; - double upBoundary = std::max(fromPoint.second, toPoint.second) + 80.0; - - std::vector> internalKnots = - generateInternalKnots(leftBoundary, rightBoundary, downBoundary, - upBoundary, 2); - - std::vector> curvePoints = - generatePoints(internalKnots); - curvePoints = distortPoints(curvePoints, 1.0, 1.0, 0.5); - points = tweenPoints(curvePoints); - } - - double easeOutQuad(double n) const { - assert(n >= 0.0 && n <= 1.0 && "Argument must be between 0.0 and 1.0."); - return -n * (n - 2); - } - - std::vector> generateInternalKnots( - double lBoundary, double rBoundary, double dBoundary, double uBoundary, - int knotsCount) const { - assert(isNumeric(lBoundary) && isNumeric(rBoundary) && - isNumeric(dBoundary) && isNumeric(uBoundary) && - "Boundaries must be numeric values"); - assert(knotsCount >= 0 && "knotsCount must be non-negative"); - assert(lBoundary <= rBoundary && - "Left boundary must be less than or equal to right boundary"); - assert(dBoundary <= uBoundary && - "Down boundary must be less than or equal to upper boundary"); - - std::vector knotsX = - randomChoiceDoubles(lBoundary, rBoundary, knotsCount); - std::vector knotsY = - randomChoiceDoubles(dBoundary, uBoundary, knotsCount); - - std::vector> knots; - for (int i = 0; i < knotsCount; i++) { - knots.emplace_back(knotsX[i], knotsY[i]); - } - return knots; - } - - std::vector randomChoiceDoubles(double min, double max, - int size) const { - std::vector choices; - std::uniform_real_distribution dist(min, max); - for (int i = 0; i < size; i++) { - choices.push_back(dist(randomEngine)); - } - return choices; - } - - std::vector> generatePoints( - const std::vector>& knots) const { - assert(isListOfPoints(knots) && "Knots must be a valid list of points"); - int midPtsCnt = static_cast( - std::max({std::abs(fromPoint.first - toPoint.first), - std::abs(fromPoint.second - toPoint.second), 2.0})); - std::vector> controlPoints = knots; - controlPoints.insert(controlPoints.begin(), fromPoint); - controlPoints.push_back(toPoint); - return BezierCalculator::calculatePointsInCurve(midPtsCnt, controlPoints); - } - - std::vector> distortPoints( - const std::vector>& points, double distortionMean, - double distortionStDev, double distortionFrequency) const { - assert(isNumeric(distortionMean) && isNumeric(distortionStDev) && - isNumeric(distortionFrequency) && "Distortions must be numeric"); - assert(isListOfPoints(points) && "Points must be a valid list of points"); - assert(0.0 <= distortionFrequency && distortionFrequency <= 1.0 && - "distortion_frequency must be in range [0,1]"); - - std::vector> distorted; - distorted.push_back(points.front()); - - std::normal_distribution normalDist(distortionMean, - distortionStDev); - std::uniform_real_distribution uniformDist(0.0, 1.0); - - for (size_t i = 1; i < points.size() - 1; i++) { - double x = points[i][0]; - double y = points[i][1]; - double delta = 0.0; - if (uniformDist(randomEngine) < distortionFrequency) { - delta = std::round(normalDist(randomEngine)); - } - distorted.push_back({x, y + delta}); - } - distorted.push_back(points.back()); - return distorted; - } - - int32_t getMaxTime() const { - if (auto maxTime = MaskConfig::GetDouble("humanize:maxTime")) { - return static_cast(maxTime.value() * 100); - } - return 150; - } - - int32_t getMinTime() const { - if (auto minTime = MaskConfig::GetDouble("humanize:minTime")) { - return static_cast(minTime.value() * 100); - } - return 0; - } - - std::vector> tweenPoints( - const std::vector>& points) const { - assert(isListOfPoints(points) && "List of points not valid"); - - double totalLength = 0.0; - for (size_t i = 1; i < points.size(); ++i) { - double dx = points[i][0] - points[i - 1][0]; - double dy = points[i][1] - points[i - 1][1]; - totalLength += std::sqrt(dx * dx + dy * dy); - } - - // Uses a power scale to keep the speed consistent - int targetPoints = std::min( - getMaxTime(), - std::max(getMinTime() + 2, static_cast(std::pow(totalLength, 0.25) * 20))); - - std::vector> res; - for (int i = 0; i < targetPoints; i++) { - double t = static_cast(i) / (targetPoints - 1); - double easedT = easeOutQuad(t); - int index = static_cast(easedT * (points.size() - 1)); - res.push_back(points[index]); - } - return res; - } - - bool isNumeric(double val) const { return !std::isnan(val); } - - bool isListOfPoints( - const std::vector>& points) const { - for (const auto& p : points) { - if (!isNumeric(p.first) || !isNumeric(p.second)) return false; - } - return true; - } - - bool isListOfPoints(const std::vector>& points) const { - for (const auto& p : points) { - if (p.size() != 2 || !isNumeric(p[0]) || !isNumeric(p[1])) return false; - } - return true; - } - - mutable std::default_random_engine randomEngine{std::random_device{}()}; -}; \ No newline at end of file diff --git a/additions/camoucfg/moz.build b/additions/camoucfg/moz.build index 3fe87d2..f0dce5b 100644 --- a/additions/camoucfg/moz.build +++ b/additions/camoucfg/moz.build @@ -8,8 +8,7 @@ with Files("**"): BUG_COMPONENT = ("Core", "DOM: UI Events & Focus Handling") EXPORTS += [ - "MaskConfig.hpp", - "MouseTrajectories.hpp", + "MaskConfig.hpp" ] LOCAL_INCLUDES += [ diff --git a/patches/chromeutil.patch b/patches/chromeutil.patch index 7bbdae5..4540607 100644 --- a/patches/chromeutil.patch +++ b/patches/chromeutil.patch @@ -7,7 +7,6 @@ index 52f0af76ec..2a7a9ae4fc 100644 #include "ChromeUtils.h" +#include "MaskConfig.hpp" -+#include "MouseTrajectories.hpp" #include "JSOracleParent.h" #include "ThirdPartyUtil.h"