checkpoint-cli 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +23 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -587,6 +587,23 @@ function trackingScript() {
|
|
|
587
587
|
return dist;
|
|
588
588
|
}
|
|
589
589
|
|
|
590
|
+
function textMatchScore(node,payload){
|
|
591
|
+
if(!payload||!payload.text_context) return 0;
|
|
592
|
+
var tc=payload.text_context;
|
|
593
|
+
var selfText=getVisibleText(node);
|
|
594
|
+
var parentText=node.parentElement?getVisibleText(node.parentElement):'';
|
|
595
|
+
var bonus=0;
|
|
596
|
+
if(tc.self&&selfText&&tc.self.length>2){
|
|
597
|
+
if(selfText===tc.self.toLowerCase()) bonus+=200;
|
|
598
|
+
else if(selfText.indexOf(tc.self.toLowerCase())>=0||tc.self.toLowerCase().indexOf(selfText)>=0) bonus+=80;
|
|
599
|
+
}
|
|
600
|
+
if(tc.parent&&parentText&&tc.parent.length>2){
|
|
601
|
+
if(parentText===tc.parent.toLowerCase()) bonus+=100;
|
|
602
|
+
else if(parentText.indexOf(tc.parent.toLowerCase())>=0||tc.parent.toLowerCase().indexOf(parentText)>=0) bonus+=40;
|
|
603
|
+
}
|
|
604
|
+
return bonus;
|
|
605
|
+
}
|
|
606
|
+
|
|
590
607
|
function pickBestElement(nodes,payload,metrics,fingerprintPath){
|
|
591
608
|
if(!nodes||nodes.length===0) return { element:null, ambiguous:false, bestScore:Infinity };
|
|
592
609
|
var target=getTargetDocPoint(payload,metrics);
|
|
@@ -594,6 +611,7 @@ function trackingScript() {
|
|
|
594
611
|
var bestScore=Infinity;
|
|
595
612
|
var secondScore=Infinity;
|
|
596
613
|
var matchCount=0;
|
|
614
|
+
var bestTextBonus=0;
|
|
597
615
|
for(var i=0;i<nodes.length;i++){
|
|
598
616
|
var node=nodes[i];
|
|
599
617
|
if(!node||node.nodeType!==1) continue;
|
|
@@ -610,10 +628,13 @@ function trackingScript() {
|
|
|
610
628
|
if(Array.isArray(fingerprintPath)&&fingerprintPath.length>0){
|
|
611
629
|
score+=siblingPathDistance(node,fingerprintPath)*40;
|
|
612
630
|
}
|
|
631
|
+
var tBonus=textMatchScore(node,payload);
|
|
632
|
+
score=Math.max(0,score-tBonus);
|
|
613
633
|
if(score<bestScore){
|
|
614
634
|
secondScore=bestScore;
|
|
615
635
|
best=node;
|
|
616
636
|
bestScore=score;
|
|
637
|
+
bestTextBonus=tBonus;
|
|
617
638
|
}else if(score<secondScore){
|
|
618
639
|
secondScore=score;
|
|
619
640
|
}
|
|
@@ -621,9 +642,9 @@ function trackingScript() {
|
|
|
621
642
|
if(!best) return { element:null, ambiguous:false, bestScore:Infinity };
|
|
622
643
|
var ambiguous=false;
|
|
623
644
|
if(matchCount>1){
|
|
624
|
-
if(!target){
|
|
645
|
+
if(!target&&bestTextBonus===0){
|
|
625
646
|
ambiguous=true;
|
|
626
|
-
}else if((secondScore-bestScore)<
|
|
647
|
+
}else if((secondScore-bestScore)<30&&bestTextBonus<80){
|
|
627
648
|
ambiguous=true;
|
|
628
649
|
}
|
|
629
650
|
}
|
|
@@ -893,7 +914,6 @@ function trackingScript() {
|
|
|
893
914
|
scrollTick=true;
|
|
894
915
|
requestAnimationFrame(function(){
|
|
895
916
|
reportScroll();
|
|
896
|
-
reportDomMutation('scroll');
|
|
897
917
|
scrollTick=false;
|
|
898
918
|
});
|
|
899
919
|
}
|