mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-25 15:53:01 +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
@@ -1,6 +1,6 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { existsSync, readFileSync, statSync } from "node:fs";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
||||
import { dirname, join, relative, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const scriptDirectory = dirname(fileURLToPath(import.meta.url));
|
||||
@@ -8,7 +8,19 @@ const repositoryRoot = resolve(scriptDirectory, "..");
|
||||
const firefoxOutputDirectory = join(repositoryRoot, "Extensions", "combined", "dist", "firefox");
|
||||
const firefoxManifestPath = join(firefoxOutputDirectory, "manifest.json");
|
||||
const contentScriptPath = join(firefoxOutputDirectory, "ryd.content-script.js");
|
||||
const menuFixerPath = join(firefoxOutputDirectory, "menu-fixer.js");
|
||||
const maxContentScriptBytes = 5 * 1024 * 1024;
|
||||
const expectedNodeVersion = "v22.17.0";
|
||||
const expectedNpmVersion = "10.8.2";
|
||||
const expectedExtensionVersion = "4.0.5";
|
||||
const expectedFirefoxExtensionId = "{762f9885-5a13-4abd-9c77-433dcd38b8fd}";
|
||||
const expectedRequiredDataCollectionPermissions = [
|
||||
"personallyIdentifyingInfo",
|
||||
"browsingActivity",
|
||||
"websiteContent",
|
||||
"websiteActivity",
|
||||
];
|
||||
const expectedOptionalDataCollectionPermissions = ["authenticationInfo"];
|
||||
const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
|
||||
const shouldUseShell = process.platform === "win32";
|
||||
|
||||
@@ -56,8 +68,39 @@ function verifyFileExists(filePath, description) {
|
||||
}
|
||||
}
|
||||
|
||||
function verifyExactArray(actual, expected, description) {
|
||||
if (
|
||||
!Array.isArray(actual) ||
|
||||
actual.length !== expected.length ||
|
||||
actual.some((value, index) => value !== expected[index])
|
||||
) {
|
||||
throw new Error(`${description} must be exactly ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`);
|
||||
}
|
||||
}
|
||||
|
||||
function collectJavaScriptFiles(directory) {
|
||||
return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
|
||||
const entryPath = join(directory, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
return collectJavaScriptFiles(entryPath);
|
||||
}
|
||||
|
||||
return entry.isFile() && entry.name.endsWith(".js") ? [entryPath] : [];
|
||||
});
|
||||
}
|
||||
|
||||
const npmVersion = readCommandOutput(npmCommand, ["--version"]);
|
||||
console.log(`Node.js: ${process.version}`);
|
||||
console.log(`npm: ${readCommandOutput(npmCommand, ["--version"])}`);
|
||||
console.log(`npm: ${npmVersion}`);
|
||||
|
||||
if (process.version !== expectedNodeVersion) {
|
||||
throw new Error(`Node.js ${expectedNodeVersion} is required, got ${process.version}`);
|
||||
}
|
||||
|
||||
if (npmVersion !== expectedNpmVersion) {
|
||||
throw new Error(`npm ${expectedNpmVersion} is required, got ${npmVersion}`);
|
||||
}
|
||||
|
||||
console.log("Installing dependencies...");
|
||||
run(npmCommand, ["ci"], {
|
||||
@@ -66,22 +109,63 @@ run(npmCommand, ["ci"], {
|
||||
},
|
||||
});
|
||||
|
||||
console.log("Building Firefox extension output...");
|
||||
run(npmCommand, ["run", "build"]);
|
||||
console.log("Building Firefox extension output with the AMO release hook...");
|
||||
run(npmCommand, ["run", "build-for-amo"]);
|
||||
|
||||
verifyFileExists(firefoxManifestPath, "Firefox manifest");
|
||||
verifyFileExists(contentScriptPath, "Firefox content script");
|
||||
verifyFileExists(menuFixerPath, "Firefox menu fixer");
|
||||
|
||||
const firefoxManifest = JSON.parse(readFileSync(firefoxManifestPath, "utf8"));
|
||||
if (firefoxManifest.version !== expectedExtensionVersion) {
|
||||
throw new Error(`Firefox manifest version must be ${expectedExtensionVersion}, got ${firefoxManifest.version}`);
|
||||
}
|
||||
|
||||
const browserSpecificSettings = firefoxManifest.browser_specific_settings;
|
||||
if (browserSpecificSettings?.gecko?.id !== expectedFirefoxExtensionId) {
|
||||
throw new Error(
|
||||
`Firefox extension ID must be ${expectedFirefoxExtensionId}, got ${browserSpecificSettings?.gecko?.id}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (browserSpecificSettings?.gecko?.strict_min_version !== "140.0") {
|
||||
throw new Error(
|
||||
`Firefox strict_min_version must be 140.0, got ${browserSpecificSettings?.gecko?.strict_min_version}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (Object.hasOwn(browserSpecificSettings ?? {}, "gecko_android")) {
|
||||
throw new Error("Firefox manifest must omit gecko_android because this release is desktop-only");
|
||||
}
|
||||
|
||||
const dataCollectionPermissions = browserSpecificSettings.gecko.data_collection_permissions;
|
||||
verifyExactArray(
|
||||
dataCollectionPermissions?.required,
|
||||
expectedRequiredDataCollectionPermissions,
|
||||
"Required data collection permissions",
|
||||
);
|
||||
verifyExactArray(
|
||||
dataCollectionPermissions?.optional,
|
||||
expectedOptionalDataCollectionPermissions,
|
||||
"Optional data collection permissions",
|
||||
);
|
||||
|
||||
const contentScriptSize = statSync(contentScriptPath).size;
|
||||
if (contentScriptSize >= maxContentScriptBytes) {
|
||||
throw new Error(`ryd.content-script.js is ${contentScriptSize} bytes, expected less than ${maxContentScriptBytes}`);
|
||||
}
|
||||
|
||||
const contentScript = readFileSync(contentScriptPath, "utf8");
|
||||
if (contentScript.includes("sourceMappingURL")) {
|
||||
throw new Error("ryd.content-script.js contains a source map reference");
|
||||
const generatedJavaScriptFiles = collectJavaScriptFiles(firefoxOutputDirectory);
|
||||
for (const generatedJavaScriptFile of generatedJavaScriptFiles) {
|
||||
if (readFileSync(generatedJavaScriptFile, "utf8").includes("sourceMappingURL")) {
|
||||
throw new Error(`${relative(firefoxOutputDirectory, generatedJavaScriptFile)} contains a source map reference`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Verifying generated extension artifact provenance...");
|
||||
run(npmCommand, ["run", "check:extension-artifact"]);
|
||||
|
||||
console.log(`Firefox output: ${firefoxOutputDirectory}`);
|
||||
console.log(`ryd.content-script.js: ${contentScriptSize} bytes`);
|
||||
console.log(`Verified ${generatedJavaScriptFiles.length} generated JavaScript files without source map references.`);
|
||||
console.log("AMO source build completed successfully.");
|
||||
Reference in new issue
Block a user