|
99 | 99 | var step = allowOverlapping ? 1 : subString.length;
|
100 | 100 | while (true) {
|
101 | 101 | pos = string.indexOf(subString, pos);
|
102 |
| - if (pos >= 0) { |
103 |
| - ++n; |
104 |
| - pos += step; |
105 |
| - } |
| 102 | + if (pos >= 0) { ++n; pos += step; } |
106 | 103 | else break;
|
107 | 104 | }
|
108 | 105 | return n;
|
|
156 | 153 | child_count_by_attr = [];
|
157 | 154 | for (var i = 0; i < non_id_attributes.length; i++) {
|
158 | 155 | selector_by_attr[i] = null;
|
159 |
| - if (non_id_attributes[i] == 'class') |
| 156 | + if (non_id_attributes[i] == 'class') { |
160 | 157 | selector_by_attr[i] = selector_by_class;
|
| 158 | + } |
161 | 159 | else {
|
162 | 160 | selector_by_attr[i] = cssPathByAttribute(el, non_id_attributes[i]);
|
163 | 161 | }
|
|
174 | 172 | basic_tags.push('h1');
|
175 | 173 | basic_tags.push('h2');
|
176 | 174 | basic_tags.push('h3');
|
| 175 | + basic_tags.push('center'); |
177 | 176 | basic_tags.push('input');
|
178 | 177 | basic_tags.push('textarea');
|
179 | 178 | for (var i = 0; i < basic_tags.length; i++) {
|
|
211 | 210 | t_count += 1;
|
212 | 211 | }
|
213 | 212 | if (t_count === 1 && !inner_text.includes('\n')) {
|
214 |
| - inner_text = inner_text.replace("'", "\\'"); |
215 |
| - inner_text = inner_text.replace('"', '\\"'); |
| 213 | + inner_text = inner_text.replaceAll("'", "\\'"); |
| 214 | + inner_text = inner_text.replaceAll('"', '\\"'); |
216 | 215 | return tag_name += ':contains("'+inner_text+'")';
|
217 | 216 | }
|
218 | 217 | }
|
|
227 | 226 | qsa_element = "span";
|
228 | 227 | if (parent_tag_name == "button")
|
229 | 228 | qsa_element = "button > span";
|
230 |
| - else { qsa_element = "button > "+parent_tag_name+" > span" } |
| 229 | + else |
| 230 | + qsa_element = "button > "+parent_tag_name+" > span"; |
231 | 231 | t_count = 0;
|
232 | 232 | all_el_found = document.querySelectorAll(qsa_element);
|
233 | 233 | for (var j = 0; j < all_el_found.length; j++) {
|
234 | 234 | if (all_el_found[j].innerText.includes(inner_text))
|
235 | 235 | t_count += 1;
|
236 | 236 | }
|
237 | 237 | if (t_count === 1 && !inner_text.includes('\n')) {
|
238 |
| - inner_text = inner_text.replace("'", "\\'"); |
239 |
| - inner_text = inner_text.replace('"', '\\"'); |
| 238 | + inner_text = inner_text.replaceAll("'", "\\'"); |
| 239 | + inner_text = inner_text.replaceAll('"', '\\"'); |
240 | 240 | return qsa_element += ':contains("'+inner_text+'")';
|
241 | 241 | }
|
242 | 242 | }
|
|
299 | 299 | sessionStorage.setItem('pause_recorder', 'no');
|
300 | 300 | sessionStorage.setItem('recorder_mode', '1');
|
301 | 301 | const d_now = Date.now();
|
| 302 | + w_orig = window.location.origin; |
| 303 | + w_href = window.location.href; |
302 | 304 | if (sessionStorage.getItem('recorder_activated') === 'yes') {
|
303 | 305 | ss_ra = JSON.parse(sessionStorage.getItem('recorded_actions'));
|
304 | 306 | document.recorded_actions = ss_ra;
|
305 |
| - w_orig = window.location.origin; |
306 |
| - w_href = window.location.href; |
307 |
| - ra_len = document.recorded_actions.length; |
308 |
| - if (ra_len > 0 && document.recorded_actions[ra_len-1][0] === 'begin') { |
309 |
| - document.recorded_actions.pop(); |
310 |
| - document.recorded_actions.push(['begin', w_orig, w_href, d_now]); |
311 |
| - } |
312 |
| - else if (ra_len > 0 && |
313 |
| - document.recorded_actions[ra_len-1][0] === '_url_') |
314 |
| - { |
315 |
| - document.recorded_actions.pop(); |
316 |
| - document.recorded_actions.push(['_url_', w_orig, w_href, d_now]); |
317 |
| - } |
318 |
| - else { |
319 |
| - document.recorded_actions.push(['_url_', w_orig, w_href, d_now]); |
320 |
| - } |
| 307 | + document.recorded_actions.push(['_url_', w_orig, w_href, d_now]); |
321 | 308 | }
|
322 | 309 | else {
|
323 | 310 | sessionStorage.setItem('recorder_activated', 'yes');
|
324 |
| - w_orig = window.location.origin; |
325 |
| - w_href = window.location.href; |
326 | 311 | document.recorded_actions.push(['begin', w_orig, w_href, d_now]);
|
327 | 312 | }
|
328 | 313 | json_rec_act = JSON.stringify(document.recorded_actions);
|
|
368 | 353 | {
|
369 | 354 | document.recorded_actions.pop();
|
370 | 355 | }
|
371 |
| - if (element.draggable === true) |
| 356 | + if (element.draggable === true) { |
372 | 357 | document.recorded_actions.push(['drags', selector, '', d_now]);
|
| 358 | + } |
373 | 359 | json_rec_act = JSON.stringify(document.recorded_actions);
|
374 | 360 | sessionStorage.setItem('recorded_actions', json_rec_act);
|
375 | 361 | });
|
|
450 | 436 | document.recorded_actions[ra_len-1][1] === selector &&
|
451 | 437 | tag_name === 'input' && e_type === 'checkbox')
|
452 | 438 | {
|
453 |
| - // The checkbox state only needs to be set once. (Pop duplicates.) |
| 439 | + // Pop duplicate checkbox state changes. |
454 | 440 | document.recorded_actions.pop();
|
455 | 441 | ra_len = document.recorded_actions.length;
|
456 | 442 | if (ra_len > 0 && document.recorded_actions[ra_len-1][1] === selector)
|
|
474 | 460 | const selector = getBestSelector(element);
|
475 | 461 | ra_len = document.recorded_actions.length;
|
476 | 462 | tag_name = element.tagName.toLowerCase();
|
477 |
| - if (ra_len > 0 && document.recorded_actions[ra_len-1][0] === 'mo_dn') { |
| 463 | + if (ra_len > 0 && document.recorded_actions[ra_len-1][0] === 'mo_dn') |
478 | 464 | document.recorded_actions.pop();
|
479 |
| - } |
480 | 465 | if (tag_name === 'select') {
|
481 | 466 | // Do Nothing. (Handle select in 'change' action.)
|
482 | 467 | }
|
483 |
| - else { |
| 468 | + else |
484 | 469 | document.recorded_actions.push(['mo_dn', selector, '', d_now]);
|
485 |
| - } |
486 | 470 | json_rec_act = JSON.stringify(document.recorded_actions);
|
487 | 471 | sessionStorage.setItem('recorded_actions', json_rec_act);
|
488 | 472 | });
|
|
506 | 490 | document.recorded_actions[ra_len-1][0] === 'mo_dn' &&
|
507 | 491 | document.recorded_actions[ra_len-1][1] === selector)
|
508 | 492 | {
|
509 |
| - if (rec_mode === '2') { |
| 493 | + sel_has_contains = selector.includes(':contains('); |
| 494 | + if (rec_mode === '2' || (rec_mode === '3' && sel_has_contains)) { |
510 | 495 | origin = window.location.origin;
|
511 | 496 | document.recorded_actions.push(['as_el', selector, origin, d_now]);
|
512 | 497 | return;
|
513 | 498 | }
|
514 | 499 | else if (rec_mode === '3') {
|
515 | 500 | origin = window.location.origin;
|
516 |
| - text = element.textContent; |
| 501 | + text = element.innerText; |
| 502 | + action = 'as_et'; |
517 | 503 | if (!text) { text = ''; }
|
| 504 | + else { |
| 505 | + text = text.trim(); |
| 506 | + var match = /\r|\n/.exec(text); |
| 507 | + if (match) { |
| 508 | + lines = text.split(/\r\n|\r|\n/g); |
| 509 | + text = ''; |
| 510 | + for (var i = 0; i < lines.length; i++) { |
| 511 | + if (lines[i].length > 0) { |
| 512 | + action = 'as_te'; text = lines[i]; break; |
| 513 | + } |
| 514 | + } |
| 515 | + } |
| 516 | + } |
518 | 517 | tex_sel = [text, selector];
|
519 |
| - document.recorded_actions.push(['as_te', tex_sel, origin, d_now]); |
| 518 | + document.recorded_actions.push([action, tex_sel, origin, d_now]); |
520 | 519 | return;
|
521 | 520 | }
|
522 | 521 | }
|
|
566 | 565 | child_count > 2 && !grand_element.hasAttribute('onclick')))
|
567 | 566 | {
|
568 | 567 | w_orig = window.location.origin;
|
569 |
| - if (origin === w_orig) { |
| 568 | + if (origin === w_orig) |
570 | 569 | document.recorded_actions.push(['_url_', origin, href, d_now]);
|
571 |
| - } |
572 |
| - else { |
| 570 | + else |
573 | 571 | document.recorded_actions.push(['begin', origin, href, d_now]);
|
574 |
| - } |
575 | 572 | }
|
576 |
| - else { |
| 573 | + else |
577 | 574 | document.recorded_actions.push(['click', selector, href, d_now]);
|
578 |
| - } |
579 | 575 | // Switch to hover_click() if in a dropdown.
|
580 | 576 | if (element.parentElement.classList.contains('dropdown-content') &&
|
581 | 577 | element.parentElement.parentElement.classList.contains('dropdown'))
|
|
603 | 599 | else if (ra_len > 0 &&
|
604 | 600 | document.recorded_actions[ra_len-1][0] === 'mo_dn')
|
605 | 601 | {
|
606 |
| - // Probably an accidental drag & drop action. |
| 602 | + // Probably an accidental drag & drop. |
607 | 603 | document.recorded_actions.pop();
|
608 | 604 | }
|
609 | 605 | json_rec_act = JSON.stringify(document.recorded_actions);
|
|
644 | 640 | document.body.addEventListener('keyup', function (event) {
|
645 | 641 | if (typeof document.recorded_actions === 'undefined')
|
646 | 642 | reset_recorder_state();
|
647 |
| - // Controls for Pausing and Resuming the Recorder. |
| 643 | + // Controls for Pausing & Resuming. |
648 | 644 | pause_rec = sessionStorage.getItem('pause_recorder');
|
649 | 645 | if (event.key.toLowerCase() === 'escape' && pause_rec === 'no')
|
650 | 646 | {
|
|
0 commit comments