()
| 46 | } |
| 47 | |
| 48 | async init() { |
| 49 | try { |
| 50 | console.time('MovementFaker'); |
| 51 | process.chdir(__dirname); |
| 52 | const html = await MovementFaker.httpGet(URL); |
| 53 | const script = REG_SCRIPT.exec(html); |
| 54 | |
| 55 | if (script) { |
| 56 | const [, scriptUrl, filename] = script; |
| 57 | const jsContent = await this.getJSContent(filename, scriptUrl); |
| 58 | const fnMock = new Function; |
| 59 | const ctx = { |
| 60 | window: { addEventListener: fnMock }, |
| 61 | document: { |
| 62 | addEventListener: fnMock, |
| 63 | removeEventListener: fnMock, |
| 64 | cookie: this.cookie, |
| 65 | }, |
| 66 | navigator: { userAgent: this.ua }, |
| 67 | }; |
| 68 | |
| 69 | vm.createContext(ctx); |
| 70 | vm.runInContext(jsContent, ctx); |
| 71 | smashUtils = ctx.window.smashUtils; |
| 72 | smashUtils.init(DATA); |
| 73 | |
| 74 | // console.log(ctx); |
| 75 | } |
| 76 | |
| 77 | // console.log(html); |
| 78 | // console.log(script[1],script[2]); |
| 79 | console.timeEnd('MovementFaker'); |
| 80 | } catch (e) { |
| 81 | console.log(e) |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | async getJSContent(cacheKey, url) { |
| 86 | try { |
no test coverage detected