Skip to content

Commit

Permalink
support electron (fix #16)
Browse files Browse the repository at this point in the history
  • Loading branch information
sayem314 committed May 20, 2020
1 parent 72c096b commit fd80462
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
10 changes: 6 additions & 4 deletions lib/core.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
const { JSDOM } = require('jsdom');
const { NodeVM } = require('vm2');
const vm = require('vm');
const delay = require('./delay');

// Solve challange with this function
Expand All @@ -19,13 +19,15 @@ const solve = async (url, html) => {

// Retrive answers from form to submit challenge
const body = [];
const vm = new NodeVM({ sandbox: { document, body } });
await vm.run(`${jschl_answer}
vm.runInNewContext(
`${jschl_answer}
// Retrive answers from form to submit challenge
const input = document.getElementsByTagName("input");
for (const i of input) {
body.push(i.name + "=" + encodeURIComponent(i.value));
}`);
}`,
{ document, body }
);

// Parse request information
const { method, action, enctype } = document.getElementById('challenge-form');
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"dependencies": {
"jsdom": "^16.2.2",
"tough-cookie": "^4.0.0",
"user-agents": "^1.0.559",
"vm2": "^3.9.2"
"user-agents": "^1.0.559"
},
"devDependencies": {
"eslint": "^7.0.0",
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1836,11 +1836,6 @@ [email protected]:
core-util-is "1.0.2"
extsprintf "^1.2.0"

vm2@^3.9.2:
version "3.9.2"
resolved "https://registry.yarnpkg.com/vm2/-/vm2-3.9.2.tgz#a4085d2d88a808a1b3c06d5478c2db3222a9cc30"
integrity sha512-nzyFmHdy2FMg7mYraRytc2jr4QBaUY3TEGe3q3bK8EgS9WC98wxn2jrPxS/ruWm+JGzrEIIeufKweQzVoQEd+Q==

w3c-hr-time@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd"
Expand Down

0 comments on commit fd80462

Please sign in to comment.