-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
93 lines (77 loc) · 2.37 KB
/
Copy pathdeploy.js
File metadata and controls
93 lines (77 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const playwright = require('playwright');
const fs = require('fs');
require('dotenv').config();
const appLocation = process.env.APP_LOCATION;
let mainText, perchanceText, modified;
try {
mainText = fs.readFileSync('filo-index.html', 'utf8');
} catch {
mainText = false;
}
try {
perchanceText = fs.readFileSync('perchance.txt', 'utf8');
} catch {
perchanceText = false;
}
(async () => {
const browser = await playwright.chromium.launch(
{
headless: false,
args: [
"--start-maximized",
"--user-agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5615.138 Safari/537.36'",
"--lang=en-US"
]
}
);
const context = await browser.newContext({ viewport: null });
const page = await context.newPage({
bypassCSP: true,
});
await page.goto(appLocation);
await page.bringToFront();
await page.route('**/*', (route, request) => {
route.continue({
headers: {
...request.headers(),
'X-Frame-Options': 'ALLOW',
'Access-Control-Allow-Origin': '*',
},
});
});
page.on('dialog', async dialog => await dialog.accept());
await page.waitForSelector('#mainOutputTemplateEditorCtn', { state: 'visible' });
await page.evaluate(() => {
document.documentElement.style.userSelect = 'none';
document.querySelector('#aiHelperCtn').hidden = true;
});
await page.waitForTimeout(1200);
if (mainText) {
await page.evaluate((mainText) => {
document.querySelector('#mainOutputTemplateEditorCtn *[role="textbox"]').innerText = '';
setTimeout(() => {
document.querySelector('#mainOutputTemplateEditorCtn *[role="textbox"]').innerText = mainText;
}, 1000);
}, mainText);
modified = true;
}
if (perchanceText) {
await page.evaluate((perchanceText) => {
document.querySelector('#mainModelTextEditorCtn *[role="textbox"]').innerText = '';
setTimeout(() => {
document.querySelector('#mainModelTextEditorCtn *[role="textbox"]').innerText = perchanceText;
}, 1000);
}, perchanceText);
modified = true;
}
if (modified) {
await page.evaluate(() => {
app.saveGenerator();
});
}
await page.waitForFunction(() => {
window.menuBar && window.menuBar.saveState === 'saved'
}, { timeout: 600000 });
await page.waitForTimeout(1200);
await browser.close();
})();