import {Template} from '../../template.js' import jsdom from "jsdom"; import {Window} from 'happy-dom' ; import fs from 'fs' export class Main extends Template { constructor() { super() this.profile = { title: '京东保险天天领权益', crontab: 3 } } async prepare() { let ua = this.userAgents().jd let resourceLoader = new jsdom.ResourceLoader({ userAgent: ua, "referer": "https://iu.jr.jd.com/", }); let virtualConsole = new jsdom.VirtualConsole(); this.jsConfig = { "url": "https://iu.jr.jd.com/", "referer": "https://iu.jr.jd.com/", "userAgent": ua, runScripts: "dangerously", resources: resourceLoader, includeNodeLocations: true, storageQuota: 10000000, pretendToBeVisual: true, virtualConsole, }; let JSDOM = jsdom.JSDOM let a = new JSDOM(`
`, this.jsConfig) await this.wait(1000) if (a.window.AAR2) { a.window.AAR2.init(); this.crypto = { aar: new a.window.AAR2(), cry: a.window.cryptico } } else { this.log("jsdom没有获取到aar2") this.jump = 1 } // let jsFiles = [ // 'aar2.min.js', // 'cryptico.min.js', // 'jrbridge.js', // ]; // const window = new Window(); // const document = window.document; // for (let i of jsFiles) { // const jsCode = fs.readFileSync(`${this.abspath}/static/${i}`, 'utf-8'); // const scriptElement = document.createElement('script'); // scriptElement.textContent = jsCode; // document.body.appendChild(scriptElement); // } // document.body.innerHTML = ' '; // window.AAR2.init(); // this.crypto = { // aar: new window.AAR2(), // cry: window.cryptico // } // console.log(this.crypto.aar.nonce()) // console.log(this.crypto.aar.sign(234,this.crypto.aar.nonce())) // this.jump=234 } async main(p) { let user = p.data.user; let context = p.context; let a = new jsdom.JSDOM(`