19 lines
945 B
JavaScript
19 lines
945 B
JavaScript
// 移除 HubNotice 弹窗挂载,避免与原生公告弹窗重复
|
|
const fs = require("fs");
|
|
const target = "/app/.next/static/chunks/402-" + /* placeholder */ "3f8ac71d6e5b0924" + ".js";
|
|
// find the chunk dynamically
|
|
const dir = "/app/.next/static/chunks/";
|
|
const fs2 = require("fs");
|
|
const files = fs2.readdirSync(dir).filter(f => /^402-.*\.js$/.test(f));
|
|
if (files.length !== 1) { console.log("expected 1 402 chunk, found", files); process.exit(0); }
|
|
const t = dir + files[0];
|
|
const MARK = "/*HUBNOTICE-REMOVED*/";
|
|
let s = fs2.readFileSync(t, "utf8");
|
|
if (s.includes(MARK)) { console.log("hubnotice-remove: skip (already)"); process.exit(0); }
|
|
const needle = "(0,a.jsx)(HubNotice,{})";
|
|
const idx = s.indexOf(needle);
|
|
if (idx < 0) { console.error("HubNotice mount not found"); process.exit(1); }
|
|
s = s.slice(0, idx) + MARK + s.slice(idx + needle.length);
|
|
fs2.writeFileSync(t, s);
|
|
console.log("hubnotice-remove: removed mount in", files[0]);
|