playworks converter

This commit is contained in:
2026-05-28 14:23:48 +08:00
parent cce30c0729
commit 2921d4d384
13 changed files with 27 additions and 30 deletions

View File

@@ -10,20 +10,6 @@ const root = process.cwd();
const dogCatRoot = process.env.DOGCAT_ROOT || path.join(root, 'aiAssets', 'DogCat3');
const waitMs = Number(process.env.RUNTIME_WAIT_MS || 9000);
const htmlFiles = [
['Applovin', path.join(dogCatRoot, 'Applovin', 'wat_mip_grhpl_dogcat3_05_real_na_noseason_en_full_na_al.html')],
['Facebook', path.join(dogCatRoot, 'Facebook', 'wat_mip_grhpl_dogcat3_05_real_na_noseason_en_full_na_fb.html')],
['Ironsource', path.join(dogCatRoot, 'Ironsource', 'wat_mip_grhpl_dogcat3_05_real_na_noseason_en_full_na_is.html')],
['Moloco', path.join(dogCatRoot, 'Moloco', 'wat_mip_grhpl_dogcat3_05_real_na_noseason_en_full_na_mo.html')],
['Unity', path.join(dogCatRoot, 'Unity', 'wat_mip_grhpl_dogcat3_05_real_na_noseason_en_full_na_un.html')],
];
const zipFiles = [
['GoogleAds', path.join(dogCatRoot, 'GoogleAds', 'wat_mip_grhpl_dogcat3_05_real_na_noseason_en_full_na_gg.zip')],
['Mintegral', path.join(dogCatRoot, 'Mintegral', 'wat_mip_grhpl_dogcat3_05_real_na_noseason_en_full_na_mtg.zip')],
['Vungle', path.join(dogCatRoot, 'Vungle', 'wat_mip_grhpl_dogcat3_05_real_na_noseason_en_full_na_vu.zip')],
];
const mraidStub = `
window.mraid = window.mraid || {
getState: function(){ return 'default'; },
@@ -44,20 +30,36 @@ window.ExitApi = window.ExitApi || {
async function collectCases(tempDir) {
const cases = [];
for (const [name, file] of htmlFiles) {
if (existsSync(file)) cases.push([name, await readFile(file)]);
}
for (const [name, zip] of zipFiles) {
if (!existsSync(zip)) continue;
const networkFolders = [
'Applovin',
'Facebook',
'Ironsource',
'Moloco',
'Unity',
'GoogleAds',
'Mintegral',
'Vungle',
];
for (const name of networkFolders) {
const dir = path.join(dogCatRoot, name);
if (!existsSync(dir)) continue;
const entries = await readdir(dir);
const htmlName = entries.find((entry) => /\.html?$/i.test(entry));
if (htmlName) {
cases.push([name, await readFile(path.join(dir, htmlName))]);
continue;
}
const zipName = entries.find((entry) => /\.zip$/i.test(entry));
if (!zipName) continue;
const zip = path.join(dir, zipName);
const out = path.join(tempDir, name);
execFileSync('powershell', [
'-NoProfile',
'-Command',
`Expand-Archive -LiteralPath '${zip.replaceAll("'", "''")}' -DestinationPath '${out.replaceAll("'", "''")}' -Force`,
], { stdio: 'ignore' });
const entries = await readdir(out);
const indexName = entries.find((entry) => entry.toLowerCase() === 'index.html');
const expanded = await readdir(out);
const indexName = expanded.find((entry) => entry.toLowerCase() === 'index.html');
if (indexName) cases.push([name, await readFile(path.join(out, indexName))]);
}
return cases;