Class: Ronin::Web::CLI::JSShell Private

Inherits:
Core::CLI::Shell
  • Object
show all
Defined in:
lib/ronin/web/cli/js_shell.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Represents a JavaScript shell for a browser.

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(browser, **kwargs) ⇒ JSShell

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the JavaScript shell.

Parameters:

  • browser (Ronin::Web::Browser::Agent)

    The browser instance.

Since:

  • 1.0.0



44
45
46
47
48
# File 'lib/ronin/web/cli/js_shell.rb', line 44

def initialize(browser,**kwargs)
  super(**kwargs)

  @browser = browser
end

Instance Attribute Details

#browserRonin::Web::Browser::Agent (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The parent browser.

Returns:

  • (Ronin::Web::Browser::Agent)

Since:

  • 1.0.0



36
37
38
# File 'lib/ronin/web/cli/js_shell.rb', line 36

def browser
  @browser
end

Instance Method Details

#exec(js) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Evaluates the JavaScript in the current browser page.

Parameters:

  • js (String)

    The JavaScript to evaluate.

Since:

  • 1.0.0



56
57
58
59
60
61
62
63
64
# File 'lib/ronin/web/cli/js_shell.rb', line 56

def exec(js)
  value = @browser.eval_js(js)

  unless value.nil?
    p value
  end
rescue Ferrum::JavaScriptError => error
  puts error.message
end