update: 2026-03-28 20:59
This commit is contained in:
25
InfoGenie-frontend/scripts/inject-ig-embed.js
Normal file
25
InfoGenie-frontend/scripts/inject-ig-embed.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const root = path.join(__dirname, '../public/60sapi');
|
||||
const tag = '<script src="/60sapi/ig-embed.js"></script>';
|
||||
|
||||
function walk(dir) {
|
||||
for (const f of fs.readdirSync(dir)) {
|
||||
const p = path.join(dir, f);
|
||||
if (fs.statSync(p).isDirectory()) walk(p);
|
||||
else if (f.endsWith('.html')) {
|
||||
let c = fs.readFileSync(p, 'utf8');
|
||||
if (c.includes('ig-embed.js')) continue;
|
||||
if (!c.includes('</head>')) {
|
||||
console.warn('skip', p);
|
||||
continue;
|
||||
}
|
||||
c = c.replace('</head>', `${tag}\n</head>`);
|
||||
fs.writeFileSync(p, c, 'utf8');
|
||||
console.log('ok', p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
walk(root);
|
||||
Reference in New Issue
Block a user