mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-09-12 09:58:20 +02:00
3657de9b2c
Harden Shorts controls, reaction state, and navigation; share voting logic with the extension; improve ratio-bar rendering; and add comprehensive Jest, Playwright, artifact, and live-browser regression coverage.
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
const crypto = require("node:crypto");
|
|
|
|
const LIVE_BUILD_ID_PATTERN = /^[a-f0-9]{32}$/;
|
|
|
|
function createLiveBuildId(enabled) {
|
|
return enabled ? crypto.randomBytes(16).toString("hex") : "";
|
|
}
|
|
|
|
class LiveBuildMarkerPlugin {
|
|
constructor(buildId, assetNames) {
|
|
if (!LIVE_BUILD_ID_PATTERN.test(buildId)) {
|
|
throw new TypeError("A live build marker requires a 32-character hexadecimal build ID.");
|
|
}
|
|
this.assetNames = assetNames;
|
|
this.buildId = buildId;
|
|
}
|
|
|
|
apply(compiler) {
|
|
compiler.hooks.thisCompilation.tap("LiveBuildMarkerPlugin", (compilation) => {
|
|
compilation.hooks.processAssets.tap(
|
|
{
|
|
name: "LiveBuildMarkerPlugin",
|
|
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
|
|
},
|
|
() => {
|
|
const source = new compiler.webpack.sources.RawSource(`${JSON.stringify({ buildId: this.buildId })}\n`);
|
|
for (const assetName of this.assetNames) {
|
|
compilation.emitAsset(assetName, source);
|
|
}
|
|
},
|
|
);
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
LIVE_BUILD_ID_PATTERN,
|
|
LiveBuildMarkerPlugin,
|
|
createLiveBuildId,
|
|
};
|