mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-29 09:27:54 +01:00
Prepare 4.0.5 Firefox update and Shorts fixes
Add Firefox data consent, repair contributor sign-in, and introduce optional Hide clutter buttons. Harden video navigation, voting, and action layouts with shared browser regression coverage and reproducible release packaging.
This commit is contained in:
1 parent
3657de9b2c
commit
e500088e65
196 files changed
+39706
-2694
No files matched your search
@@ -0,0 +1,42 @@
|
||||
const USER_ID_PATTERN = /^[A-Za-z0-9]{36}$/;
|
||||
const FOUR_BYTE_PROOF_PATTERN = /^[A-Za-z0-9+/]{6}==$/;
|
||||
|
||||
function hasExactKeys(value, keys) {
|
||||
return (
|
||||
value !== null &&
|
||||
typeof value === "object" &&
|
||||
!Array.isArray(value) &&
|
||||
Object.keys(value).sort().join(",") === [...keys].sort().join(",")
|
||||
);
|
||||
}
|
||||
|
||||
function isFourByteProofSolution(value) {
|
||||
if (typeof value !== "string" || !FOUR_BYTE_PROOF_PATTERN.test(value)) return false;
|
||||
try {
|
||||
const bytes = Buffer.from(value, "base64");
|
||||
return bytes.length === 4 && bytes.toString("base64") === value;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isVoteProtocolBodyPairValid(voteBody, confirmationBody, { value, videoId } = {}) {
|
||||
const userId = voteBody?.userId;
|
||||
return (
|
||||
USER_ID_PATTERN.test(userId ?? "") &&
|
||||
hasExactKeys(voteBody, ["userId", "value", "videoId"]) &&
|
||||
voteBody.videoId === videoId &&
|
||||
voteBody.value === value &&
|
||||
hasExactKeys(confirmationBody, ["solution", "userId", "videoId"]) &&
|
||||
confirmationBody.userId === userId &&
|
||||
confirmationBody.videoId === videoId &&
|
||||
isFourByteProofSolution(confirmationBody.solution)
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
USER_ID_PATTERN,
|
||||
hasExactKeys,
|
||||
isFourByteProofSolution,
|
||||
isVoteProtocolBodyPairValid,
|
||||
};
|
||||
Reference in new issue
Block a user