Class: Puppeteer::Extension
- Inherits:
-
Object
- Object
- Puppeteer::Extension
- Defined in:
- lib/puppeteer/extension.rb
Overview
rbs_inline: enabled
Instance Attribute Summary collapse
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(id:, version:, name:, path:, enabled:, browser:) ⇒ Extension
constructor
A new instance of Extension.
- #pages ⇒ Object
- #trigger_action(page) ⇒ Object
- #workers ⇒ Object
Constructor Details
#initialize(id:, version:, name:, path:, enabled:, browser:) ⇒ Extension
Returns a new instance of Extension.
11 12 13 14 15 16 17 18 |
# File 'lib/puppeteer/extension.rb', line 11 def initialize(id:, version:, name:, path:, enabled:, browser:) @id = id @version = version @name = name @path = path @enabled = enabled @browser = browser end |
Instance Attribute Details
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
33 34 35 |
# File 'lib/puppeteer/extension.rb', line 33 def enabled @enabled end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
21 22 23 |
# File 'lib/puppeteer/extension.rb', line 21 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/puppeteer/extension.rb', line 27 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
30 31 32 |
# File 'lib/puppeteer/extension.rb', line 30 def path @path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
24 25 26 |
# File 'lib/puppeteer/extension.rb', line 24 def version @version end |
Instance Method Details
#pages ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/puppeteer/extension.rb', line 49 def pages extension_prefix = "chrome-extension://#{@id}" extension_targets = @browser.targets.select do |target| target_url = target.url ['page', 'background_page'].include?(target.type) && target_url.start_with?(extension_prefix) end extension_targets.filter_map do |target| target.as_page rescue nil end end |
#trigger_action(page) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/puppeteer/extension.rb', line 64 def trigger_action(page) page.browser.send(:connection).('Extensions.triggerAction', { id: @id, targetId: page._tab_id, }) end |
#workers ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/puppeteer/extension.rb', line 36 def workers extension_prefix = "chrome-extension://#{@id}" extension_targets = @browser.targets.select do |target| target.type == 'service_worker' && target.url.start_with?(extension_prefix) end extension_targets.filter_map do |target| target.worker rescue nil end end |