Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I add nightmare instances to array? #1639

Closed
Zebraslive opened this issue Aug 1, 2021 · 1 comment
Closed

How do I add nightmare instances to array? #1639

Zebraslive opened this issue Aug 1, 2021 · 1 comment

Comments

@Zebraslive
Copy link

I want to have an array of nightmare instances and reference by index. I've done this before but I can't remember how the syntax is. How can I store each new nightmare instance for referencing later?

for example maybe something like this. I want to push into array but I don't know if this is right way to do it, should I use a separate array or just change nightmare to nightmare[]?

nightmare[] = new Nightmare({
      switches: {
        'ignore-certificate-errors': true
      },
      electronPath: require('./node_modules/electron'),
  show: false
    });```
@Zebraslive Zebraslive changed the title How do I add nightmare instances to array object? How do I add nightmare instances to array? Aug 1, 2021
@Zebraslive
Copy link
Author

Never mind, figured it out.

var nightmare_instances;
window.nightmare_instances = [];
function grabLink(url, filenamex, callback = false) {
  window.nightmare_instances[filenamex] = new Nightmare({
      switches: {
        'ignore-certificate-errors': true
      },
      electronPath: require('./node_modules/electron'),
  show: false
    });
window.nightmare_instances[filenamex]
.goto(url)
 .inject('js', storagepath+'/jquery-3.0.0.js')
.wait(400)
.evaluate(function() {

return $('#videolink').text();

})
.end(function(link) {
return callback(link);
})
.then(function() {

});


}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant