xautobrowse 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/xautobrowse.rb +141 -20
- data.tar.gz.sig +4 -2
- metadata +42 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ccc76cd36b9b1a4ed1db3be63ee734bc8b4d3ba
|
4
|
+
data.tar.gz: c947ce6a6d1d718343ca9ebe71d4197ec54d0948
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63e7316ef1e5a531e853f5402e6b8482c267d785cd0730dbff0935522447e75fb90f4ca7f2843a4a29e3347a6b6c90d6af0ce29689e395e0084961e6f2c552e8
|
7
|
+
data.tar.gz: adc643a9601e25c1e09eb82ffbc4aef15998de9db43dd3ed042d90514c73359127536fa0eb170f525c5881a495ce80bb9e198b67a9c17d239a145139b312f00b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/xautobrowse.rb
CHANGED
@@ -15,13 +15,25 @@
|
|
15
15
|
require 'wmctrl'
|
16
16
|
require 'nokorexi'
|
17
17
|
require 'clipboard'
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
|
18
|
+
require 'xdo/mouse'
|
19
|
+
require 'xdo/keyboard'
|
20
|
+
require 'xdo/xwindow'
|
21
|
+
require 'universal_dom_remote'
|
22
22
|
|
23
23
|
|
24
24
|
class XAutoBrowse
|
25
|
+
|
26
|
+
at_exit() do
|
27
|
+
|
28
|
+
puts 'shutting down ...'
|
29
|
+
EventMachine.stop
|
30
|
+
sleep 3
|
31
|
+
`ruby -r sps-pub -e "SPSPub.notice('shutdown', host: \
|
32
|
+
'127.0.0.1', port: '55000'); sleep 0.4"`
|
33
|
+
|
34
|
+
|
35
|
+
end
|
36
|
+
|
25
37
|
|
26
38
|
def initialize(browser= :firefox, debug: false)
|
27
39
|
|
@@ -43,15 +55,15 @@ class XAutoBrowse
|
|
43
55
|
@id = r[:id]
|
44
56
|
|
45
57
|
@x, @y, @width, @height = *r[:geometry]
|
46
|
-
|
58
|
+
Thread.new { open_web_console(); sleep 1; close_web_console() }
|
59
|
+
|
60
|
+
connect()
|
47
61
|
end
|
48
62
|
|
49
63
|
# custom accesskey (e.g. CTRL+SHIFT+S) typically used to reference an
|
50
64
|
# element on the web page
|
51
65
|
#
|
52
|
-
def accesskey(key)
|
53
|
-
XDo::Keyboard.send key.to_sym
|
54
|
-
end
|
66
|
+
def accesskey(key) send_keys(key.to_sym) end
|
55
67
|
|
56
68
|
alias access_key accesskey
|
57
69
|
|
@@ -59,6 +71,44 @@ class XAutoBrowse
|
|
59
71
|
@wm.action_window(@id, :activate)
|
60
72
|
end
|
61
73
|
|
74
|
+
# Attaches the SPS client to the web browser. The SPS broker must be
|
75
|
+
# started before the code can be attached. see start_broker()
|
76
|
+
#
|
77
|
+
def attach_console(autohide: true)
|
78
|
+
|
79
|
+
activate()
|
80
|
+
open_web_console(); sleep 1
|
81
|
+
|
82
|
+
Clipboard.copy javascript(); sleep 1
|
83
|
+
ctrl_v(); sleep 0.5
|
84
|
+
carriage_return()
|
85
|
+
|
86
|
+
close_web_console() if autohide
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
def close_web_console()
|
91
|
+
activate()
|
92
|
+
ctrl_shift_i()
|
93
|
+
end
|
94
|
+
|
95
|
+
alias hide_web_console close_web_console
|
96
|
+
|
97
|
+
def connect()
|
98
|
+
|
99
|
+
start_broker()
|
100
|
+
sleep 5
|
101
|
+
connect_controller()
|
102
|
+
end
|
103
|
+
|
104
|
+
# Connects to the SPS broker to communicate with the web browser
|
105
|
+
#
|
106
|
+
def connect_controller()
|
107
|
+
|
108
|
+
@udr = UniversalDomRemote.new debug: @debug
|
109
|
+
|
110
|
+
end
|
111
|
+
|
62
112
|
def copy_source()
|
63
113
|
|
64
114
|
view_source(); sleep 3
|
@@ -70,23 +120,27 @@ class XAutoBrowse
|
|
70
120
|
|
71
121
|
# select all
|
72
122
|
#
|
73
|
-
def ctrl_a()
|
123
|
+
def ctrl_a() send_keys(:ctrl_a) end
|
74
124
|
|
75
125
|
# copy
|
76
126
|
#
|
77
|
-
def ctrl_c()
|
127
|
+
def ctrl_c() send_keys(:ctrl_c) end
|
78
128
|
|
79
129
|
# jump to the location bar
|
80
130
|
#
|
81
|
-
def ctrl_l()
|
131
|
+
def ctrl_l() send_keys(:ctrl_l) end
|
82
132
|
|
83
133
|
# view source code
|
84
134
|
#
|
85
|
-
def ctrl_u()
|
135
|
+
def ctrl_u() send_keys(:ctrl_u) end
|
136
|
+
|
137
|
+
# paste
|
138
|
+
#
|
139
|
+
def ctrl_v() send_keys(:ctrl_v) end
|
86
140
|
|
87
141
|
# developer tools
|
88
142
|
#
|
89
|
-
def ctrl_shift_i()
|
143
|
+
def ctrl_shift_i() send_keys(:ctrl_shift_i) end
|
90
144
|
|
91
145
|
# submit a form by pressing return
|
92
146
|
#
|
@@ -107,6 +161,7 @@ class XAutoBrowse
|
|
107
161
|
activate(); sleep 0.5
|
108
162
|
ctrl_l(); sleep 0.5
|
109
163
|
enter(url); sleep 4
|
164
|
+
attach_console()
|
110
165
|
|
111
166
|
end
|
112
167
|
|
@@ -126,16 +181,41 @@ class XAutoBrowse
|
|
126
181
|
|
127
182
|
alias cr carriage_return
|
128
183
|
|
184
|
+
def open_web_console()
|
185
|
+
|
186
|
+
console = @browser == :firefox ? :ctrl_shift_k : :ctrl_shift_i
|
187
|
+
method(console).call # web console
|
188
|
+
|
189
|
+
sleep 3
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
def send(s)
|
194
|
+
@udr.send s
|
195
|
+
end
|
196
|
+
|
197
|
+
# Starts the simplepubsub broker
|
198
|
+
|
199
|
+
def start_broker()
|
200
|
+
|
201
|
+
Thread.new do
|
202
|
+
`ruby -r 'simplepubsub' -e "SimplePubSub::Broker.start port: '55000'"`
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
def stop_broker()
|
208
|
+
SPSPub.notice 'shutdown', host: '127.0.0.1', port: '55000'
|
209
|
+
end
|
210
|
+
|
129
211
|
def tab(n=1)
|
212
|
+
activate()
|
130
213
|
XDo::Keyboard.simulate("{TAB}" * n)
|
131
214
|
end
|
132
215
|
|
133
216
|
def text_field(klass: nil, id: nil, name: nil, value: '')
|
134
217
|
|
135
|
-
|
136
|
-
method(console).call # web console
|
137
|
-
|
138
|
-
sleep 3
|
218
|
+
open_web_console()
|
139
219
|
|
140
220
|
cmd = if klass then
|
141
221
|
"r = document.querySelector('#{klass}')"
|
@@ -156,9 +236,9 @@ class XAutoBrowse
|
|
156
236
|
Nokorexi.new(Clipboard.paste).to_doc
|
157
237
|
end
|
158
238
|
|
159
|
-
|
160
|
-
|
161
|
-
end
|
239
|
+
# type some text
|
240
|
+
#
|
241
|
+
def type(s) activate(); XDo::Keyboard.type(s) end
|
162
242
|
|
163
243
|
def view_source()
|
164
244
|
|
@@ -174,4 +254,45 @@ class XAutoBrowse
|
|
174
254
|
#
|
175
255
|
def enter(s) type(s); sleep 0.8; carriage_return(); sleep 1 end
|
176
256
|
|
257
|
+
|
258
|
+
private
|
259
|
+
|
260
|
+
# A helpful method to generate the javascript code necessary for the
|
261
|
+
# web browser to communicate with the universal DOM remote
|
262
|
+
#
|
263
|
+
def javascript()
|
264
|
+
|
265
|
+
"
|
266
|
+
var ws = new WebSocket('ws://127.0.0.1:55000/');
|
267
|
+
ws.onopen = function() {
|
268
|
+
console.log('CONNECT');
|
269
|
+
ws.send('subscribe to topic: udr/controller');
|
270
|
+
};
|
271
|
+
ws.onclose = function() {
|
272
|
+
console.log('DISCONNECT');
|
273
|
+
};
|
274
|
+
ws.onmessage = function(event) {
|
275
|
+
|
276
|
+
var a = event.data.split(/: +/,2);
|
277
|
+
console.log(a[1]);
|
278
|
+
|
279
|
+
try {
|
280
|
+
r = eval(a[1]);
|
281
|
+
}
|
282
|
+
catch(err) {
|
283
|
+
r = err.message;
|
284
|
+
}
|
285
|
+
|
286
|
+
ws.send('udr/browser: ' + r);
|
287
|
+
|
288
|
+
};
|
289
|
+
"
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
def send_keys(keys)
|
294
|
+
|
295
|
+
activate(); XDo::Keyboard.send keys.to_sym
|
296
|
+
|
297
|
+
end
|
177
298
|
end
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
�
|
1
|
+
n5��}�x_2i-��%�:�fe�x���H�U.�wg�Cֹ�j�]���i�2 �6�' �n��,k�k�6�XH]Q]l$�g��
|
2
|
-
|
2
|
+
?&�7x�}Fz���m8� ��� )/�R���喲խ�q��]bI7��z_{k�'��2�T�p)�8"AH�$�Q˫�#2��%*�ď�y��H�q7�V��]=#��TͶ
|
3
|
+
١��S����T�8'&��6�Q��4%�����OU�.�u
|
4
|
+
e�C�����"�D/C��ìD�
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xautobrowse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
UkT65Cjj3pGfXSA+uRiXo7EXRM2Xft7NA1wuE91g2PYjRb8GvdqjxrgF1gp+LHtf
|
31
31
|
Gwk=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-01-
|
33
|
+
date: 2018-01-30 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: xdo
|
@@ -112,6 +112,46 @@ dependencies:
|
|
112
112
|
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: 1.1.1
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: simplepubsub
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '1.3'
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.3.2
|
125
|
+
type: :runtime
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.3'
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 1.3.2
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: universal_dom_remote
|
137
|
+
requirement: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - "~>"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0.1'
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 0.1.1
|
145
|
+
type: :runtime
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0.1'
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: 0.1.1
|
115
155
|
description:
|
116
156
|
email: james@jamesrobertson.eu
|
117
157
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|