locatine 0.02542 → 0.02637

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df3f8d995c895faf833681632462dcd884e73bce
4
- data.tar.gz: 8885ecd8b1513df7cac86761a22e02acdb692f03
3
+ metadata.gz: 8d969a9d3fc96c105d69b1d41f7ff8df92198d6d
4
+ data.tar.gz: 93ec07af0558fd08a13224686c9844775f3b36c9
5
5
  SHA512:
6
- metadata.gz: 0234243bf852972ac60752c0be0232a2c427ce0f40f21fefaaa2cf8e7a32403e2c33f8761fcaa28712ffd8bd0960b1d2c46f5f3846e45c56e51edf5b5dc2831e
7
- data.tar.gz: ec7071e6b671a03d6cf2fe034b510f914af84e403248ddcd6a3d230a9c8cf9ba4f2c291ffe9722a5a58436d3208754b5898d1a9dc94d00f9016772fcf2a6b117
6
+ metadata.gz: 6f7d7af25a50b8aeb293f3795574999e87debe5adfd3149bb3e9855257a5cf4f47c2f980c57a8582b7b65890abafc665c3d96ab39604eb4ae615bdc636489d11
7
+ data.tar.gz: 3883f1e882b88f038dcacd6520d408126e9c82b9178a5cfb2d5069d4b14a7327e25651d08a45ab447f8b4a0366341482aefc7414668d06e08aeebaa13ef2ffd0
data/README.md CHANGED
@@ -16,7 +16,11 @@ That's it.
16
16
 
17
17
  ## Stage of development:
18
18
 
19
- Version of Locatine is **0.02542** only. It means so far this is an alfa. You can use it in a real project if you are a risky person.
19
+ Version of Locatine is **0.02637** only. It means so far this is an alfa. You can use it in a real project if you are a risky person.
20
+
21
+ ## Attention
22
+
23
+ Beginning with the next version locatine (especially locatine-daemon) will be refactored dramatically. It is highly possible that the next version will be not completable with that one.
20
24
 
21
25
  ## Installation
22
26
 
@@ -20,7 +20,7 @@ div[locatinestyle=true] {
20
20
  display: block;
21
21
  z-index: 2147483646;
22
22
  color: #FF99AA;
23
- font-size: 45px;
23
+ font-size: 4vw;
24
24
  text-align: center;
25
25
  cursor: default;
26
26
  }
@@ -30,11 +30,6 @@ div[locatinestyle=false] {
30
30
  width: 0%;
31
31
  }
32
32
 
33
- div[locatinestyle=blocked] {
34
- height: 0%;
35
- width: 0%;
36
- }
37
-
38
33
  [locatineclass=foundbylocatine]
39
34
  {animation: locatine_found 6s infinite;
40
35
  -webkit-appearance: none;
@@ -46,21 +46,24 @@ async function setTitleHint(magicDiv){
46
46
  await set_value('locatine_title', magicDiv.getAttribute("locatinetitle"));
47
47
  await set_value('locatine_hint', magicDiv.getAttribute("locatinehint"));
48
48
  magicDiv.setAttribute("locatinetitle", "ok");
49
- let op = 1;
50
- magicDiv.innerHTML = await get_value("locatine_title");
51
- let timer = setInterval(function () {
52
- if ((magicDiv.style.opacity == 1) && (op < 0.97)) {
53
- clearInterval(timer);// If other process changed opacity.
54
- };
55
- if (op <= 0.2) {
56
- clearInterval(timer);
57
- magicDiv.style.opacity = 0;
58
- magicDiv.innerHTML = "";
59
- }
60
- magicDiv.style.opacity = op;
61
- magicDiv.style.filter = 'alpha(opacity=' + op * 100 + ")";
62
- op -= op * 0.03;
63
- }, 50);
49
+ let status = await get_value('magic_div');
50
+ if (status) {
51
+ let op = 1;
52
+ magicDiv.innerHTML = await get_value("locatine_title");
53
+ let timer = setInterval(function () {
54
+ if ((magicDiv.style.opacity == 1) && (op < 0.97)) {
55
+ clearInterval(timer);// If other process changed opacity.
56
+ };
57
+ if (op <= 0.2) {
58
+ clearInterval(timer);
59
+ magicDiv.style.opacity = 0;
60
+ magicDiv.innerHTML = "";
61
+ }
62
+ magicDiv.style.opacity = op;
63
+ magicDiv.style.filter = 'alpha(opacity=' + op * 100 + ")";
64
+ op -= op * 0.03;
65
+ }, 50);
66
+ }
64
67
  }
65
68
  }
66
69
 
@@ -117,7 +120,7 @@ async function getSelected(value){
117
120
  };
118
121
 
119
122
  async function locatine_magic_click(e) {
120
- document.getElementById("locatine_magic_div").setAttribute("locatinestyle", "blocked");
123
+ document.getElementById("locatine_magic_div").setAttribute("locatinestyle", "false");
121
124
  const value = document.elementFromPoint(e.clientX, e.clientY);
122
125
  document.getElementById("locatine_magic_div").setAttribute("locatinestyle", "true");
123
126
  const tagName = value.tagName;
@@ -140,7 +143,7 @@ function locatine_create_element(dom, tag, attrs, inner) {
140
143
 
141
144
  setInterval(async function(){
142
145
  if (document.getElementById("locatine_magic_div")) {
143
- if (document.getElementById("locatine_magic_div").getAttribute("locatinestyle") != "blocked") {
146
+ if (document.getElementById("locatine_magic_div").getAttribute("locatinestyle") != "false") {
144
147
  await refreshData()
145
148
  }
146
149
  } else {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "Locatine app",
3
- "version": "0.02542",
3
+ "version": "0.02637",
4
4
  "description": "Messaging from browser to main app",
5
5
  "devtools_page": "devtools.html",
6
6
  "permissions": ["activeTab", "storage", "contextMenus", "tabs"],
@@ -28,7 +28,7 @@ module Locatine
28
28
  # We are taking every element that look at least a bit similar to one we
29
29
  # are looking for
30
30
  def magic_elements(name, scope, data, vars, page)
31
- warn_element_lost(name, scope)
31
+ warn_element_lost(name, scope, data, vars)
32
32
  all = select_from_page(page, data, vars)
33
33
  raise_not_found(name, scope) if all.empty? && !@current_no_f
34
34
  suggested = most_common_of(all).map do |element|
@@ -54,7 +54,7 @@ module Locatine
54
54
  ok = similar_enough(data, attributes) unless suggest.empty?
55
55
  raise_not_similar(name, scope) if !ok && !@current_no_f
56
56
  if ok
57
- warn_lost_found(name, scope)
57
+ warn_lost_found(name, scope, attributes, vars)
58
58
  return suggest, attributes
59
59
  end
60
60
  warn_not_found(name, scope)
@@ -21,7 +21,7 @@ module Locatine
21
21
  ##
22
22
  # Sending request to locatine app
23
23
  def start_listening(scope, name)
24
- send_to_app('locatinestyle', 'blocked', @browser) if @iframe
24
+ send_to_app('locatinestyle', 'set_false', @browser) if @iframe
25
25
  send_to_app('locatinestyle', 'set_true')
26
26
  send_to_app('locatineconfirmed', 'ok')
27
27
  send_selecting(name, scope)
@@ -128,9 +128,10 @@ module Locatine
128
128
  ' :links, etc.)'
129
129
  end
130
130
 
131
- def warn_element_lost(name, scope)
132
- send_warn "#{name} in #{scope} is//are lost. Locatine is trying "\
133
- 'to find it anyway.'
131
+ def warn_element_lost(name, scope, data, vars)
132
+ xpath = generate_xpath(data, vars)
133
+ send_warn "#{name} in #{scope} by xpath: ```#{xpath}``` is//are lost."\
134
+ ' Locatine is trying to find it anyway.'
134
135
  end
135
136
 
136
137
  def warn_cannot_highlight(data)
@@ -154,8 +155,10 @@ module Locatine
154
155
  send_warn "Only the first 50 elements of #{size} were highlighted."
155
156
  end
156
157
 
157
- def warn_lost_found(name, scope)
158
- send_warn "Something was found as #{name} in #{scope}."
158
+ def warn_lost_found(name, scope, data, vars)
159
+ xpath = generate_xpath(data, vars)
160
+ send_warn "Something was found as #{name} in #{scope} by xpath:"\
161
+ "```#{xpath}```"
159
162
  end
160
163
 
161
164
  def warn_not_found(name, scope)
@@ -34,7 +34,15 @@ module Locatine
34
34
  end
35
35
 
36
36
  def generate_xpath_part(hash, vars)
37
- value = process_string(hash['value'], vars)
37
+ result = ''
38
+ values = process_string(hash['value'], vars).split(/[,.-_ ;'\\"]/)
39
+ values.each do |value|
40
+ result += generate_real_xpath_part(hash, value) if !value.empty?
41
+ end
42
+ result
43
+ end
44
+
45
+ def generate_real_xpath_part(hash, value)
38
46
  case hash['type']
39
47
  when 'tag'
40
48
  "[self::#{value}]"
@@ -1,6 +1,6 @@
1
1
  module Locatine
2
2
  # constants here...
3
- VERSION = '0.02542'.freeze
3
+ VERSION = '0.02637'.freeze
4
4
  NAME = 'locatine'.freeze
5
5
  HOME = if File.readable?("#{Dir.pwd}/lib/#{Locatine::NAME}")
6
6
  "#{Dir.pwd}/lib/#{Locatine::NAME}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locatine
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.02542'
4
+ version: '0.02637'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei Seleznev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-08 00:00:00.000000000 Z
11
+ date: 2019-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler