xautobrowse 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +0 -0
- data/lib/xautobrowse.rb +136 -0
- metadata +147 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f041542a7d5cdda69ec2726ce75c83a6fc4f3b2c
|
4
|
+
data.tar.gz: 0adcae5ccff6385fd401cac25f253e4e4adb3ffb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53af8d4f275024df3babe3cfbdb5e7efc1244e3acfbc66a1342312ada412a1c2692410d842b8d7f09ce279e6292a6d6c1ec927d99fd84b2c7fb83ce7e4a4c5f4
|
7
|
+
data.tar.gz: f38fce05205f41ebe04840fc22241c777a9c1a5714a0632fb6cee1e9a637afbd9dde35c4ee4a240681ea5a57104552df36fb49ca4a7486efdbed01444403f63b
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
U(V���u�7,�y�����2��DJ]?b��;0��W�8[�qE��.w�_ �5��j�RUP���
|
data.tar.gz.sig
ADDED
Binary file
|
data/lib/xautobrowse.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: xautobrowse.rb
|
4
|
+
|
5
|
+
# description: Runs on an X Windows system (e.g. Debian running LXDE)
|
6
|
+
# Primarily tested using Firefox (52.6.0 (64-bit)) on Debian.
|
7
|
+
|
8
|
+
require 'wmctrl'
|
9
|
+
require 'nokorexi'
|
10
|
+
require 'clipboard'
|
11
|
+
require "xdo/mouse"
|
12
|
+
require "xdo/keyboard"
|
13
|
+
require "xdo/xwindow"
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
class XAutoBrowse
|
18
|
+
|
19
|
+
def initialize(browser_name, debug: false)
|
20
|
+
|
21
|
+
@debug = debug
|
22
|
+
|
23
|
+
@wm = WMCtrl.instance
|
24
|
+
spawn(browser_name)
|
25
|
+
sleep 4
|
26
|
+
id = XDo::XWindow.wait_for_window(browser_name)
|
27
|
+
xwin = XDo::XWindow.new(id)
|
28
|
+
title = xwin.title
|
29
|
+
puts 'title: ' + title.inspect if @debug
|
30
|
+
|
31
|
+
# WMCtrl is used because XDo is problematic at trying to activate a window
|
32
|
+
|
33
|
+
a = @wm.list_windows true
|
34
|
+
puts 'a: ' + a.inspect if @debug
|
35
|
+
r = a.find {|x| x[:title] =~ /#{browser_name}$/i}
|
36
|
+
@id = r[:id]
|
37
|
+
|
38
|
+
@x, @y, @width, @height = *r[:geometry]
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
def activate()
|
43
|
+
@wm.action_window(@id, :activate)
|
44
|
+
end
|
45
|
+
|
46
|
+
def copy_source()
|
47
|
+
|
48
|
+
view_source()
|
49
|
+
sleep 3
|
50
|
+
XDo::Keyboard.ctrl_a # select all
|
51
|
+
sleep 1
|
52
|
+
XDo::Keyboard.ctrl_c # copy the source code to the clipboard
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
def go()
|
57
|
+
|
58
|
+
activate()
|
59
|
+
sleep 2
|
60
|
+
if block_given? then
|
61
|
+
yield(self)
|
62
|
+
end
|
63
|
+
|
64
|
+
XDo::Keyboard.return
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def goto(url)
|
69
|
+
|
70
|
+
@wm.action_window(@id, :activate)
|
71
|
+
sleep 0.5
|
72
|
+
XDo::Keyboard.ctrl_l
|
73
|
+
sleep 0.5
|
74
|
+
XDo::Keyboard.type(url)
|
75
|
+
XDo::Keyboard.return
|
76
|
+
sleep 5
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
def move(x,y)
|
81
|
+
@x, @y = x, y
|
82
|
+
@wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
|
83
|
+
end
|
84
|
+
|
85
|
+
def resize(width, height)
|
86
|
+
@width, @height = width, height
|
87
|
+
@wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
|
88
|
+
end
|
89
|
+
|
90
|
+
def text_field(klass: nil, id: nil, name: nil, value: '')
|
91
|
+
|
92
|
+
XDo::Keyboard.ctrl_shift_k # web console
|
93
|
+
sleep 5
|
94
|
+
|
95
|
+
if klass then
|
96
|
+
XDo::Keyboard.type("r = document.querySelector('#{klass}')")
|
97
|
+
elsif id then
|
98
|
+
XDo::Keyboard.type("r = document.getElementById(\"#{id}\")")
|
99
|
+
end
|
100
|
+
sleep 3
|
101
|
+
XDo::Keyboard.return
|
102
|
+
sleep 2
|
103
|
+
XDo::Keyboard.type("r.value = \"\"")
|
104
|
+
sleep 2
|
105
|
+
XDo::Keyboard.return
|
106
|
+
sleep 1
|
107
|
+
XDo::Keyboard.type("r.focus()")
|
108
|
+
sleep 2
|
109
|
+
XDo::Keyboard.return
|
110
|
+
sleep 2
|
111
|
+
XDo::Keyboard.ctrl_shift_i # toggle tools
|
112
|
+
sleep 2
|
113
|
+
XDo::Keyboard.type(value)
|
114
|
+
sleep 2
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
def to_doc()
|
119
|
+
copy_source()
|
120
|
+
sleep 0.5
|
121
|
+
Nokorexi.new(Clipboard.paste).to_doc
|
122
|
+
end
|
123
|
+
|
124
|
+
def view_source()
|
125
|
+
|
126
|
+
@wm.action_window(@id, :activate)
|
127
|
+
sleep 0.5
|
128
|
+
XDo::Keyboard.ctrl_l # jump to the location bar
|
129
|
+
sleep 0.6
|
130
|
+
XDo::Keyboard.simulate("{TAB}" * 2)
|
131
|
+
sleep 0.5
|
132
|
+
XDo::Keyboard.ctrl_u # View source code
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xautobrowse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwMTI4MjAyNDU4WhcN
|
15
|
+
MTkwMTI4MjAyNDU4WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDe2taT
|
17
|
+
/dJPt5XfCyUrKbJipb/qV5mwjvQtVCT0ZhT/90ElNIgi48fPrGmUSzkkXyAp5l1W
|
18
|
+
Np9hNhWSLiaDPuhRy5j5UeS6gSCbc+sFtje6Xz/znQ9uFteGhlDyxBmSowVTQA84
|
19
|
+
wLlXm91aeaIvdlu+QA05IpXLjj3Bz6N3pIU3+mr0oASHEBSIA0iioA7L/ipyfaay
|
20
|
+
USkC2ftpSegshul4gw9jzzu/S//UzN7LUFMGzPO7MuHnkz1EJHNHpS+X28zXSr6r
|
21
|
+
i1E3L16JDLNeK7QGOszLHJEj+yp5AkX/RPZOsn7cHxXO62htwOdajJLoJn+8kClS
|
22
|
+
qSFVL+GsQ9LP2KqjAgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
23
|
+
HQYDVR0OBBYEFFNxeKas0hLc+Eexllb0wF8oyAswMCYGA1UdEQQfMB2BG2dlbW1h
|
24
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTAmBgNVHRIEHzAdgRtnZW1tYXN0ZXJAamFt
|
25
|
+
ZXNyb2JlcnRzb24uZXUwDQYJKoZIhvcNAQEFBQADggEBADUp7oImwi9elESr391y
|
26
|
+
GXwgycXUXBelPyx746D+xhREysTzHEM8dCLed1S82AbIq+LibQFrKCjvZ0zwVPvy
|
27
|
+
mexSOTSYqv+RYWmIgfn0Zys0u8A/LCpaBUc2QxZuk8ErvdJ44nPBm8UTuHQqDs0Z
|
28
|
+
+Y3XTLjWjAgK8AKAsJ4eY1itn/Ei8sFSlXj2dhw8deSWI26ZXt2cr0H8ThY0bQN3
|
29
|
+
0yTrmlrZvG19r0IG46cF1B1iRcUx1MQ1roQHrt1B02oNmKC1ZTF4ggUdesby+Fwg
|
30
|
+
UkT65Cjj3pGfXSA+uRiXo7EXRM2Xft7NA1wuE91g2PYjRb8GvdqjxrgF1gp+LHtf
|
31
|
+
Gwk=
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2018-01-28 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: xdo
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0.0'
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 0.0.4
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - "~>"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0.0'
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.4
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ruby-wmctrl
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.0'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.0.6
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0.0'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.0.6
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: nokorexi
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0.3'
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 0.3.2
|
85
|
+
type: :runtime
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0.3'
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.3.2
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: clipboard
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '1.1'
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 1.1.1
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1.1'
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 1.1.1
|
115
|
+
description:
|
116
|
+
email: james@jamesrobertson.eu
|
117
|
+
executables: []
|
118
|
+
extensions: []
|
119
|
+
extra_rdoc_files: []
|
120
|
+
files:
|
121
|
+
- lib/xautobrowse.rb
|
122
|
+
homepage: https://github.com/jrobertson/xautobrowse
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 2.5.0
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.6.13
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: A poor man's web automation tool primarily for ' + 'Firefox in an X
|
146
|
+
windows system.
|
147
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|