-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay.js
38 lines (32 loc) · 1.06 KB
/
play.js
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
const puppeteer = require("puppeteer");
var fs = require("fs");
let file;
const script = fs.readFileSync(__dirname + "\\rrweb\\rrweb.js", "utf8");
const style = fs.readFileSync(__dirname + "\\rrweb\\rrweb.css", "utf8");
console.log(__dirname);
const run_browser = async () => {
const events = fs.readFileSync(file, "utf8");
const browser = await puppeteer.launch({
headless: false,
defaultViewport: null,
args: ["--no-sandbox", "--disable-setuid-sandbox", "--start-maximized"]
});
const pages = await browser.pages();
const page = pages[0];
//await page.goto("file://" + file);
await page.evaluate(script);
await page.addStyleTag({ content: style });
await page.evaluate(`events=${events};new rrweb.Replayer(events).play();`);
};
const open_file = files => {
file = files[0].path;
console.log(file);
load_replay();
};
const load_replay = () => {
console.log("should open puppeteer");
console.log("file is", file);
run_browser();
};
exports.open_file = open_file;
exports.load_replay = load_replay;