|
11 | 11 | var selector = el.nodeName.toLowerCase();
|
12 | 12 | if (el.id) {
|
13 | 13 | elid = el.id;
|
14 |
| - if (elid.includes('.') || elid.includes('(') || elid.includes(')')) |
| 14 | + if (elid.includes(',') || elid.includes('.') || |
| 15 | + elid.includes('(') || elid.includes(')')) |
15 | 16 | return cssPathByAttribute(el, 'id');
|
16 | 17 | selector += '#' + elid;
|
17 | 18 | path.unshift(selector);
|
|
107 | 108 | return n;
|
108 | 109 | };
|
109 | 110 | function hasNumber(str) {
|
110 |
| - return /\d/.test(str); |
| 111 | + return /\d/.test(str); |
111 | 112 | };
|
112 | 113 | function tagName(el) {
|
113 |
| - return el.tagName.toLowerCase(); |
| 114 | + return el.tagName.toLowerCase(); |
114 | 115 | };
|
115 | 116 | function turnIntoParentAsNeeded(el) {
|
116 | 117 | if (tagName(el) == 'span') {
|
|
402 | 403 | const el = event.target;
|
403 | 404 | const selector = getBestSelector(el);
|
404 | 405 | ra_len = document.recorded_actions.length;
|
| 406 | + rec_mode = sessionStorage.getItem('recorder_mode'); |
| 407 | + if (rec_mode === '2' || rec_mode === '3') |
| 408 | + return; |
405 | 409 | if (ra_len > 0 &&
|
406 | 410 | document.recorded_actions[ra_len-1][0] === 'mo_dn' &&
|
407 | 411 | document.recorded_actions[ra_len-1][1] === selector)
|
|
505 | 509 | ra_len = document.recorded_actions.length;
|
506 | 510 | rec_mode = sessionStorage.getItem('recorder_mode');
|
507 | 511 | tag_name = tagName(el);
|
508 |
| - text = ''; |
509 | 512 | if (rec_mode === '2' || rec_mode === '3')
|
| 513 | + { |
510 | 514 | el = turnIntoParentAsNeeded(el);
|
511 | 515 | texts = [el.innerText, el.textContent];
|
512 |
| - if (ra_len > 0 && document.recorded_actions[ra_len-1][0] === 'mo_dn') |
513 |
| - document.recorded_actions.pop(); |
514 |
| - if (tag_name === 'select') { |
515 |
| - // Do Nothing. ('change' action.) |
516 |
| - } |
517 |
| - else |
518 |
| - document.recorded_actions.push(['mo_dn', selector, texts, d_now]); |
519 |
| - json_rec_act = JSON.stringify(document.recorded_actions); |
520 |
| - sessionStorage.setItem('recorded_actions', json_rec_act); |
521 |
| -}); |
522 |
| -document.body.addEventListener('mouseup', function (event) { |
523 |
| - reset_if_recorder_undefined(); |
524 |
| - if (sessionStorage.getItem('pause_recorder') === 'yes') return; |
525 |
| - const d_now = Date.now(); |
526 |
| - const el = event.target; |
527 |
| - selector = getBestSelector(el); |
528 |
| - ra_len = document.recorded_actions.length; |
529 |
| - tag_name = tagName(el); |
530 |
| - parent_el = el.parentElement; |
531 |
| - parent_tag_name = tagName(parent_el); |
532 |
| - grand_el = ""; |
533 |
| - grand_tag_name = ""; |
534 |
| - origin = ""; |
535 |
| - rec_mode = sessionStorage.getItem('recorder_mode'); |
536 |
| - if (ra_len > 0 && document.recorded_actions[ra_len-1][0] === 'mo_dn' && |
537 |
| - (rec_mode === '2' || rec_mode === '3')) |
538 |
| - { |
539 |
| - pre_sel = document.recorded_actions[ra_len-1][1]; |
540 |
| - sel_has_contains = pre_sel.includes(':contains('); |
541 |
| - texts = document.recorded_actions[ra_len-1][2]; |
542 | 516 | text = texts[0];
|
543 | 517 | t_con = texts[1];
|
544 | 518 | origin = window.location.origin;
|
| 519 | + sel_has_contains = selector.includes(':contains('); |
545 | 520 | if (!text) { text = ''; }
|
546 | 521 | if (rec_mode === '2' || (
|
547 | 522 | rec_mode === '3' && sel_has_contains && text === t_con))
|
548 | 523 | {
|
549 |
| - document.recorded_actions.push(['as_el', pre_sel, origin, d_now]); |
| 524 | + document.recorded_actions.push(['as_el', selector, origin, d_now]); |
550 | 525 | json_rec_act = JSON.stringify(document.recorded_actions);
|
551 | 526 | sessionStorage.setItem('recorded_actions', json_rec_act);
|
552 | 527 | return;
|
|
564 | 539 | }
|
565 | 540 | }
|
566 | 541 | }
|
567 |
| - tex_sel = [text, pre_sel]; |
| 542 | + tex_sel = [text, selector]; |
568 | 543 | document.recorded_actions.push([action, tex_sel, origin, d_now]);
|
569 | 544 | json_rec_act = JSON.stringify(document.recorded_actions);
|
570 | 545 | sessionStorage.setItem('recorded_actions', json_rec_act);
|
571 | 546 | return;
|
572 | 547 | }
|
573 | 548 | }
|
| 549 | + if (ra_len > 0 && document.recorded_actions[ra_len-1][0] === 'mo_dn') |
| 550 | + document.recorded_actions.pop(); |
| 551 | + if (tag_name === 'select') { |
| 552 | + // Do Nothing. ('change' action.) |
| 553 | + } |
| 554 | + else |
| 555 | + document.recorded_actions.push(['mo_dn', selector, '', d_now]); |
| 556 | + json_rec_act = JSON.stringify(document.recorded_actions); |
| 557 | + sessionStorage.setItem('recorded_actions', json_rec_act); |
| 558 | +}); |
| 559 | +document.body.addEventListener('mouseup', function (event) { |
| 560 | + reset_if_recorder_undefined(); |
| 561 | + if (sessionStorage.getItem('pause_recorder') === 'yes') return; |
| 562 | + const d_now = Date.now(); |
| 563 | + const el = event.target; |
| 564 | + selector = getBestSelector(el); |
| 565 | + ra_len = document.recorded_actions.length; |
| 566 | + tag_name = tagName(el); |
| 567 | + parent_el = el.parentElement; |
| 568 | + parent_tag_name = tagName(parent_el); |
| 569 | + grand_el = ""; |
| 570 | + grand_tag_name = ""; |
| 571 | + origin = ""; |
| 572 | + rec_mode = sessionStorage.getItem('recorder_mode'); |
| 573 | + if (rec_mode === '2' || rec_mode === '3') |
| 574 | + return; |
574 | 575 | if (parent_el.parentElement != null) {
|
575 | 576 | grand_el = parent_el.parentElement;
|
576 | 577 | grand_tag_name = tagName(grand_el);
|
|
0 commit comments