From 4693e30302c6fcd15c9447eaac9102c570a54cf3 Mon Sep 17 00:00:00 2001 From: Claudio Gamboa Date: Tue, 24 Feb 2026 02:42:55 +0000 Subject: [PATCH] Added nested iframes support and recording coordinates on canvas elements --- package.json | 2 +- src/manifest-firefox.json | 2 +- src/pages/Content/index.js | 94 +++++++++++++++++++++- src/pages/Content/modules/collectEvents.js | 51 +++++++++++- src/pages/Review/Review.jsx | 4 + test-build-firefox/contentScript.bundle.js | 2 +- test-build-firefox/manifest.json | 2 +- test-build-firefox/reviewpage.bundle.js | 2 +- test-build/contentScript.bundle.js | 2 +- test-build/manifest.json | 2 +- test-build/reviewpage.bundle.js | 2 +- 11 files changed, 153 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index a37642c..2b575dd 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "snyk-api-and-web-record-sequence", - "version": "1.0.0", + "version": "1.1.0", "description": "Snyk API & Web Record login/sequence", "license": "MIT", "scripts": { diff --git a/src/manifest-firefox.json b/src/manifest-firefox.json index 4e66bc9..4660825 100755 --- a/src/manifest-firefox.json +++ b/src/manifest-firefox.json @@ -1,6 +1,6 @@ { "name": "Snyk API & Web Sequence Recorder", - "version": "1.0.0", + "version": "1.1.0", "browser_specific_settings": { "gecko": { "id": "sequence-recorder@probely.com", diff --git a/src/pages/Content/index.js b/src/pages/Content/index.js index a1130cf..2e0327c 100644 --- a/src/pages/Content/index.js +++ b/src/pages/Content/index.js @@ -49,8 +49,21 @@ import getCustomSelector from './modules/getCustomSelector'; evMsg.data.source && evMsg.data.source === 'event-from-iframe' ) { - const obj = { ...evMsg.data.obj }; + // Verify the message actually came from a child iframe const aFrames = document.querySelectorAll('iframe, frame'); + let isFromChildFrame = false; + for (const frame of aFrames) { + if (frame.contentWindow === evMsg.source) { + isFromChildFrame = true; + break; + } + } + if (!isFromChildFrame) { + return; // Message didn't come from any of our iframes + } + + const obj = { ...evMsg.data.obj }; + const framePath = evMsg.data.framePath || []; for (const frame of aFrames) { if (frame.contentWindow === evMsg.source) { let frameSelector = null; @@ -81,7 +94,9 @@ import getCustomSelector from './modules/getCustomSelector'; } } if (frameSelector && obj.event) { - obj.event.frame = frameSelector; + // Build the complete frame path: [outermost, ..., innermost] + const completeFramePath = [frameSelector, ...framePath]; + obj.event.frame = completeFramePath.join(' >>> '); chrome.runtime.sendMessage(obj); } break; @@ -91,17 +106,90 @@ import getCustomSelector from './modules/getCustomSelector'; }); } + // intermediate frames: listen for messages from child iframes and forward to parent + if (window !== window.top) { + window.addEventListener('message', (evMsg) => { + if ( + evMsg.data && + evMsg.data.source && + evMsg.data.source === 'event-from-iframe' + ) { + // Verify the message actually came from a child iframe + const aFrames = document.querySelectorAll('iframe, frame'); + let isFromChildFrame = false; + for (const frame of aFrames) { + if (frame.contentWindow === evMsg.source) { + isFromChildFrame = true; + break; + } + } + if (!isFromChildFrame) { + return; // Message didn't come from any of our iframes + } + + // This is an intermediate frame - find the child iframe and add to path + const framePath = evMsg.data.framePath || []; + + for (const frame of aFrames) { + if (frame.contentWindow === evMsg.source) { + let frameSelector = null; + try { + frameSelector = getCustomSelector(frame); + } catch (ex) { + // ignore + } + if (!frameSelector) { + try { + frameSelector = getNodeSelector(frame, { + root: window.document, + idName: (name) => { + return !/^[0-9]+.*/i.test(name); + }, + className: (name) => { + return ( + !name.includes('focus') && + !name.includes('highlight') && + !/^[0-9]+.*/i.test(name) + ); + }, + }); + } catch (ex) { + // ignore + } + } + + // Forward to parent with this frame's selector added to path + if (frameSelector) { + framePath.push(frameSelector); + } + + window.parent.postMessage( + { + source: 'event-from-iframe', + obj: evMsg.data.obj, + framePath: framePath, + }, + '*' + ); + break; + } + } + } + }); + } + function eventInterceptopMainHandler(ev) { if (ev && ev.type === 'mouseover' && !mutationDetected) { return; } interceptEvents(ev, window.document, null, (obj) => { if (window !== window.top) { - // If the event is inside a frame, send it to the top + // If the event is inside a frame, send it to the parent window.parent.postMessage( { source: 'event-from-iframe', obj: { ...obj }, + framePath: [], // Start with empty path, will be built as message bubbles up }, '*' ); diff --git a/src/pages/Content/modules/collectEvents.js b/src/pages/Content/modules/collectEvents.js index d36c248..75ae049 100644 --- a/src/pages/Content/modules/collectEvents.js +++ b/src/pages/Content/modules/collectEvents.js @@ -133,15 +133,64 @@ export function interceptEvents(event, doc, ifrSelector, callback) { return; } } + let typeStr = 'click'; + if (nodeName === 'canvas') { + const rect = tgt.getBoundingClientRect(); + const x = event.clientX - rect.left; + const y = event.clientY - rect.top; + const width = rect.width; + const height = rect.height; + + const clickData = { x, y, width, height }; + oEventBase = { ...oEventBase, coords: clickData }; + + typeStr = 'bclick'; + } oEventToSend = { ...oEventBase, - type: 'click', + type: typeStr, value: (tgt.value || tgt.textContent || '') .trim() .substr(0, 20) .replace(/\n/gi, ''), frame: ifrSelector, }; + + // Add shadow host CSS selector for bclick events inside shadow DOM + if (typeStr === 'bclick' && shadowRootIdx > -1 && composedPath) { + const shadowRoot = composedPath[shadowRootIdx]; + const shadowHost = shadowRoot.host; + if (shadowHost) { + let shadowHostSelector = null; + try { + shadowHostSelector = getCustomSelector(shadowHost, doc); + } catch (ex) { + // ignore + } + if (!shadowHostSelector) { + try { + shadowHostSelector = getNodeSelector(shadowHost, { + root: doc, + idName: (name) => { + return !/^[0-9]+.*/i.test(name); + }, + className: (name) => { + return ( + !name.includes('focus') && + !name.includes('highlight') && + !/^[0-9]+.*/i.test(name) + ); + }, + }); + } catch (ex) { + // ignore + } + } + if (shadowHostSelector) { + oEventToSend.shadow_host_css = shadowHostSelector; + } + } + } } else if (type === 'dblclick') { lastNodes.dblclick = tgt; oEventToSend = { diff --git a/src/pages/Review/Review.jsx b/src/pages/Review/Review.jsx index d950f6b..0c0e0d2 100644 --- a/src/pages/Review/Review.jsx +++ b/src/pages/Review/Review.jsx @@ -244,6 +244,10 @@ const Review = (props) => { case 'goto': newType = 'go to'; break; + case 'click': + case 'bclick': + newType = 'click'; + break; default: newType = type; break; diff --git a/test-build-firefox/contentScript.bundle.js b/test-build-firefox/contentScript.bundle.js index 0f74816..c0943a6 100644 --- a/test-build-firefox/contentScript.bundle.js +++ b/test-build-firefox/contentScript.bundle.js @@ -1 +1 @@ -(()=>{"use strict";let e,t;function n(n,o){if(n.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===n.tagName.toLowerCase())return"html";const i={root:document.body,idName:e=>!0,className:e=>!0,tagName:e=>!0,attr:(e,t)=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4};e={...i,...o},t=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(e.root,i);let a=r(n,"all",(()=>r(n,"two",(()=>r(n,"one",(()=>r(n,"none")))))));if(a){const e=w(v(a,n));return e.length>0&&(a=e[0]),l(a)}throw new Error("Selector was not found.")}function r(t,n,r){let l=null,i=[],a=t,g=0;for(;a;){let t=h(u(a))||h(...s(a))||h(...c(a))||h(f(a))||[{name:"*",penalty:3}];const y=d(a);if("all"==n)y&&(t=t.concat(t.filter(p).map((e=>m(e,y)))));else if("two"==n)t=t.slice(0,1),y&&(t=t.concat(t.filter(p).map((e=>m(e,y)))));else if("one"==n){const[e]=t=t.slice(0,1);y&&p(e)&&(t=[m(e,y)])}else"none"==n&&(t=[{name:"*",penalty:3}],y&&(t=[m(t[0],y)]));for(let e of t)e.level=g;if(i.push(t),i.length>=e.seedMinLength&&(l=o(i,r),l))break;a=a.parentElement,g++}return l||(l=o(i,r)),!l&&r?r():l}function o(t,n){const r=w(y(t));if(r.length>e.threshold)return n?n():null;for(let e of r)if(a(e))return e;return null}function l(e){let t=e[0],n=t.name;for(let r=1;r ${n}`:`${e[r].name} ${n}`,t=e[r]}return n}function i(e){return e.map((e=>e.penalty)).reduce(((e,t)=>e+t),0)}function a(e){const n=l(e);switch(t.querySelectorAll(n).length){case 0:throw new Error(`Can't select any node with this selector: ${n}`);case 1:return!0;default:return!1}}function u(t){const n=t.getAttribute("id");return n&&e.idName(n)?{name:"#"+CSS.escape(n),penalty:0}:null}function s(t){const n=Array.from(t.attributes).filter((t=>e.attr(t.name,t.value)));return n.map((e=>({name:`[${CSS.escape(e.name)}="${CSS.escape(e.value)}"]`,penalty:.5})))}function c(t){return Array.from(t.classList).filter(e.className).map((e=>({name:"."+CSS.escape(e),penalty:1})))}function f(t){const n=t.tagName.toLowerCase();return e.tagName(n)?{name:n,penalty:2}:null}function d(e){const t=e.parentNode;if(!t)return null;let n=t.firstChild;if(!n)return null;let r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}function m(e,t){return{name:e.name+`:nth-child(${t})`,penalty:e.penalty+1}}function p(e){return"html"!==e.name&&!e.name.startsWith("#")}function h(...e){const t=e.filter(g);return t.length>0?t:null}function g(e){return null!=e}function*y(e,t=[]){if(e.length>0)for(let n of e[0])yield*y(e.slice(1,e.length),t.concat(n));else yield t}function w(e){return[...e].sort(((e,t)=>i(e)-i(t)))}function*v(t,n,r={counter:0,visited:new Map}){if(t.length>2&&t.length>e.optimizedMinLength)for(let o=1;oe.maxNumberOfTries)return;r.counter+=1;const i=[...t];i.splice(o,1);const u=l(i);if(r.visited.has(u))return;a(i)&&b(i,n)&&(yield i,r.visited.set(u,!0),yield*v(i,n,r))}}function b(e,n){return t.querySelector(l(e))===n}function N(e,t){let n="",r=null,o=!1;try{if(r=e.nodeName&&"string"==typeof e.nodeName?e.nodeName.toLowerCase():null,!r)return null;n=`${r}`,e.getAttribute("id")&&(n=`${n}#${CSS.escape(e.getAttribute("id"))}`,o=!0);const t=["data-test-id","data-testid","data-test","data-cy"];if(e.matches(t.map((e=>`[${e}]`)).join(",")))for(const r of t){const t=e.getAttribute(r);if(t){n=`${n}[${r}="${CSS.escape(t)}"]`;break}}if(["input","button","textarea","select","option"].includes(r)){e.getAttribute("type")&&(n=`${n}[type="${CSS.escape(e.getAttribute("type"))}"]`),e.getAttribute("name")&&(n=`${n}[name="${CSS.escape(e.getAttribute("name"))}"]`);const t=e.closest("form");if(t){let e="form";t.getAttribute("id")&&(e=`${e}#${CSS.escape(t.getAttribute("id"))}`),n=`${e} ${n}`}}const l=e.getAttribute("aria-label");if(l&&!o&&(n=`${n}[aria-label="${CSS.escape(l)}"]`),n){const t=e.closest("body");if(t)try{1!==t.querySelectorAll(n).length&&(n="")}catch(e){n=""}}}catch(e){}return n}function E(e,t){let n,r=e,o=[];for(;r;){let e=0,n=r.previousElementSibling;for(;n;)n.nodeName===r.nodeName&&e++,n=n.previousElementSibling;let l=r.nodeName.toLowerCase();e>0&&(l=l+"["+(e+1)+"]"),r!==t&&o.unshift(l),r=r.parentNode}if(n="/"+o.join("/"),function(e,t){const n=t.evaluate(e,t,null,XPathResult.ANY_TYPE,null),r=n.iterateNext();return r}(n,t)===e)return n}const S={},C={keydown:null,return:null,blur:null,change:null,click:null,dblclick:null,contextmenu:null,focus:null,mouseover:null,mouseout:null};let $=!1;function A(e,t){let n;var r;let o,l;function i(e,t,r){let l=null;const i=[];let u=e,s=0;for(;u&&u!==o.root.parentElement;){let e=w(f(u))||w(...d(u))||w(...m(u))||w(p(u))||[{name:"*",penalty:3}];const c=h(u);if(t===n.All)c&&(e=e.concat(e.filter(y).map((e=>g(e,c)))));else if(t===n.Two)e=e.slice(0,1),c&&(e=e.concat(e.filter(y).map((e=>g(e,c)))));else if(t===n.One){const[t]=e=e.slice(0,1);c&&y(t)&&(e=[g(t,c)])}for(const t of e)t.level=s;if(i.push(e),i.length>=o.seedMinLength&&(l=a(i,r),l))break;u=u.parentElement,s++}return l||(l=a(i,r)),l}function a(e,t){const n=N(b(e));if(n.length>o.threshold)return t?t():null;for(const e of n)if(c(e))return e;return null}function u(e){let t=e[0],n=t.name;for(let r=1;r ${n}`:`${e[r].name} ${n}`,t=e[r]}return n}function s(e){return e.map((e=>e.penalty)).reduce(((e,t)=>e+t),0)}function c(e){switch(l.querySelectorAll(u(e)).length){case 0:throw new Error(`Can't select any node with this selector: ${u(e)}`);case 1:return!0;default:return!1}}function f(e){const t=e.getAttribute("id");return t&&o.idName(t)?{name:`#${L(t,{isIdentifier:!0})}`,penalty:0}:null}function d(e){return Array.from(e.attributes).filter((e=>o.attr(e.name,e.value))).map((e=>({name:"["+L(e.name,{isIdentifier:!0})+'="'+L(e.value)+'"]',penalty:.5})))}function m(e){return Array.from(e.classList).filter(o.className).map((e=>({name:"."+L(e,{isIdentifier:!0}),penalty:1})))}function p(e){const t=e.tagName.toLowerCase();return o.tagName(t)?{name:t,penalty:2}:null}function h(e){const t=e.parentNode;if(!t)return null;let n=t.firstChild;if(!n)return null;let r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}function g(e,t){return{name:e.name+`:nth-child(${t})`,penalty:e.penalty+1}}function y(e){return"html"!==e.name&&!e.name.startsWith("#")}function w(...e){const t=e.filter(v);return 0s(e)-s(t)))}function E(e,t){return l.querySelector(u(e))===t}(r=n||(n={}))[r.All=0]="All",r[r.Two=1]="Two",r[r.One=2]="One";const S=/[ -,\.\/:-@\[-\^`\{-~]/,C=/[ -,\.\/:-@\[\]\^`\{-~]/,$=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,A={escapeEverything:!1,isIdentifier:!1,quotes:"single",wrap:!1};function L(e,t={}){const n=Object.assign(Object.assign({},A),t);"single"!==n.quotes&&"double"!==n.quotes&&(n.quotes="single");const r="double"==n.quotes?'"':"'",o=n.isIdentifier,l=e.charAt(0);let i="",a=0;for(const t=e.length;as||126=s&&a!0,className:()=>!0,tagName:()=>!0,attr:()=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4};o=Object.assign(Object.assign({},T),t),l=function(e,t){return e.nodeType===Node.DOCUMENT_NODE?e:e===t.root?e.ownerDocument:e}(o.root,T);let x=i(e,n.All,(()=>i(e,n.Two,(()=>i(e,n.One)))));if(x){const t=N(function*e(t,n,r={counter:0,visited:new Map}){if(2o.optimizedMinLength)for(let l=1;lo.maxNumberOfTries)return;r.counter+=1;const i=[...t];i.splice(l,1);const a=u(i);if(r.visited.has(a))return;c(i)&&E(i,n)&&(yield i,r.visited.set(a,!0),yield*e(i,n,r))}}(x,e));return 0{if(!l.isRecording)return;let i=!1,a=null;function u(e){e&&"mouseover"===e.type&&!i||function(e,t,r,o){let l=!1,i=null,a=null;e&&e.composed&&e.composedPath&&(a=e.composedPath());let u=-1;a&&a.length>0&&(u=a.findIndex((e=>e instanceof ShadowRoot))),i=u>-1?a[0]:e.target;const s=e.type;let c=null,f=null;if(!i||!i.getAttribute)return;c=i.nodeName.toLowerCase(),f=i.getAttribute("type");let d=null,m=null;try{m=function(e){let t=null;try{if(t=e.nodeName&&"string"==typeof e.nodeName?e.nodeName.toLowerCase():null,!t)return e;if(["input","button","a","textarea","select","option","progress"].includes(t))return e;const n=e.closest("button,a");if(n)return n;const r=e.closest("svg");r&&(e=r);const o=["data-test-id","data-testid","data-test","data-cy"];if(e.matches(o.map((e=>`[${e}]`)).join(",")))return e;if(e.parentNode.matches(o.map((e=>`[${e}]`)).join(",")))return e.parentNode}catch(e){}return e}(i),d=N(m)}catch(e){}if(!d)try{d=n(m,{root:t,idName:e=>!/^[0-9]+.*/i.test(e),className:e=>!e.includes("focus")&&!e.includes("highlight")&&!/^[0-9]+.*/i.test(e)})}catch(e){}if(d&&"html"===d.toLowerCase())return;let p=null;try{p=E(m,t)}catch(e){}u>-1&&(p="/html/node/shadow");let h={timestamp:(new Date).getTime(),css:d||i,xpath:p||""},g={};if("click"===s){if(C.click=i,!(C.return!==C.change||i===C.return||"input"!==c&&"button"!==c||"submit"!==f&&"image"!==f||null===C.return))return;if("input"===c&&("checkbox"===f||"radio"===f))return;if("label"===c){const e=i.getAttribute("for");if(e&&document.getElementById(e))return}g={...h,type:"click",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r}}else if("dblclick"===s)C.dblclick=i,g={...h,type:"dblclick",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r};else if("contextmenu"===s)C.contextmenu=i,g={...h,type:"contextmenu",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r};else if("focus"===s);else if("mouseover"===s)$&&(clearTimeout($),$=!1),$=setTimeout((()=>{$=!1,C.mouseover=i,g={...h,type:"mouseover",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r},g&&g.type&&o&&o({messageType:"events",event:{...g}})}),500);else if("mouseout"===s);else if("keydown"===s)C.keydown=i,["input","textarea"].indexOf(c)>-1&&(S[i]=i.value),"input"===c&&13===e.keyCode&&(l=!0,C.return=i,g={...h,type:"fill_value",value:i.value,frame:r});else if("blur"===s){if(C.blur=i,["input","textarea"].indexOf(c)>-1){if(S[i]=i.value,i===C.return)return void(C.return=null);if("input"===c&&("submit"===i.type||"button"===i.type||"image"===i.type))return;g={...h,type:"fill_value",value:i.value,frame:r}}}else if("change"===s)if(C.change=i,"input"===c)"checkbox"!==f&&"radio"!==f||(g={...h,type:"change",subtype:"check",checked:i.checked,frame:r});else if("select"===c)if(i.multiple){const e=[];for(let t=0;t{window!==window.top?window.parent.postMessage({source:"event-from-iframe",obj:{...e}},"*"):chrome.runtime.sendMessage(e)}))}window===window.top&&window.addEventListener("message",(e=>{if(e.data&&e.data.source&&"event-from-iframe"===e.data.source){const t={...e.data.obj},n=document.querySelectorAll("iframe, frame");for(const r of n)if(r.contentWindow===e.source){let e=null;try{e=N(r)}catch(e){}if(!e)try{e=A(r,{root:window.document,idName:e=>!/^[0-9]+.*/i.test(e),className:e=>!e.includes("focus")&&!e.includes("highlight")&&!/^[0-9]+.*/i.test(e)})}catch(e){}e&&t.event&&(t.event.frame=e,chrome.runtime.sendMessage(t));break}}})),l.isRecording&&(t=!0,e=document.title,function(){if(!t)return document.title=`${e}`,o=!1,void(r&&(clearInterval(r),r=!1));r=setInterval((()=>{o?(document.title=`${e}`,o=!1):(document.title=`🔴 ${e}`,o=!0)}),1e3)}(),window===window.top&&chrome.runtime.sendMessage({messageType:"events",event:{type:"goto",timestamp:(new Date).getTime(),windowWidth:window.innerWidth,windowHeight:window.innerHeight,url:window.location.href}}),document.addEventListener("click",u,!0),document.addEventListener("mouseover",u,!0),document.addEventListener("dblclick",u,!0),document.addEventListener("contextmenu",u,!0),document.addEventListener("keydown",u,!0),document.addEventListener("blur",u,!0),document.addEventListener("change",u,!0));const s={attributes:!1,childList:!0,subtree:!0},c=new MutationObserver((async(e,t)=>{i=!0,a&&(clearTimeout(a),a=null),a=setTimeout((()=>{i=!1}),200)}));document.body&&c.observe(document.body,s)}))}()})(); \ No newline at end of file +(()=>{"use strict";let e,t;function n(n,o){if(n.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===n.tagName.toLowerCase())return"html";const l={root:document.body,idName:e=>!0,className:e=>!0,tagName:e=>!0,attr:(e,t)=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4};e={...l,...o},t=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(e.root,l);let a=r(n,"all",(()=>r(n,"two",(()=>r(n,"one",(()=>r(n,"none")))))));if(a){const e=w(b(a,n));return e.length>0&&(a=e[0]),i(a)}throw new Error("Selector was not found.")}function r(t,n,r){let i=null,l=[],a=t,g=0;for(;a;){let t=p(s(a))||p(...c(a))||p(...u(a))||p(f(a))||[{name:"*",penalty:3}];const y=d(a);if("all"==n)y&&(t=t.concat(t.filter(h).map((e=>m(e,y)))));else if("two"==n)t=t.slice(0,1),y&&(t=t.concat(t.filter(h).map((e=>m(e,y)))));else if("one"==n){const[e]=t=t.slice(0,1);y&&h(e)&&(t=[m(e,y)])}else"none"==n&&(t=[{name:"*",penalty:3}],y&&(t=[m(t[0],y)]));for(let e of t)e.level=g;if(l.push(t),l.length>=e.seedMinLength&&(i=o(l,r),i))break;a=a.parentElement,g++}return i||(i=o(l,r)),!i&&r?r():i}function o(t,n){const r=w(y(t));if(r.length>e.threshold)return n?n():null;for(let e of r)if(a(e))return e;return null}function i(e){let t=e[0],n=t.name;for(let r=1;r ${n}`:`${e[r].name} ${n}`,t=e[r]}return n}function l(e){return e.map((e=>e.penalty)).reduce(((e,t)=>e+t),0)}function a(e){const n=i(e);switch(t.querySelectorAll(n).length){case 0:throw new Error(`Can't select any node with this selector: ${n}`);case 1:return!0;default:return!1}}function s(t){const n=t.getAttribute("id");return n&&e.idName(n)?{name:"#"+CSS.escape(n),penalty:0}:null}function c(t){const n=Array.from(t.attributes).filter((t=>e.attr(t.name,t.value)));return n.map((e=>({name:`[${CSS.escape(e.name)}="${CSS.escape(e.value)}"]`,penalty:.5})))}function u(t){return Array.from(t.classList).filter(e.className).map((e=>({name:"."+CSS.escape(e),penalty:1})))}function f(t){const n=t.tagName.toLowerCase();return e.tagName(n)?{name:n,penalty:2}:null}function d(e){const t=e.parentNode;if(!t)return null;let n=t.firstChild;if(!n)return null;let r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}function m(e,t){return{name:e.name+`:nth-child(${t})`,penalty:e.penalty+1}}function h(e){return"html"!==e.name&&!e.name.startsWith("#")}function p(...e){const t=e.filter(g);return t.length>0?t:null}function g(e){return null!=e}function*y(e,t=[]){if(e.length>0)for(let n of e[0])yield*y(e.slice(1,e.length),t.concat(n));else yield t}function w(e){return[...e].sort(((e,t)=>l(e)-l(t)))}function*b(t,n,r={counter:0,visited:new Map}){if(t.length>2&&t.length>e.optimizedMinLength)for(let o=1;oe.maxNumberOfTries)return;r.counter+=1;const l=[...t];l.splice(o,1);const s=i(l);if(r.visited.has(s))return;a(l)&&v(l,n)&&(yield l,r.visited.set(s,!0),yield*b(l,n,r))}}function v(e,n){return t.querySelector(i(e))===n}function N(e,t){let n="",r=null,o=!1;try{if(r=e.nodeName&&"string"==typeof e.nodeName?e.nodeName.toLowerCase():null,!r)return null;n=`${r}`,e.getAttribute("id")&&(n=`${n}#${CSS.escape(e.getAttribute("id"))}`,o=!0);const t=["data-test-id","data-testid","data-test","data-cy"];if(e.matches(t.map((e=>`[${e}]`)).join(",")))for(const r of t){const t=e.getAttribute(r);if(t){n=`${n}[${r}="${CSS.escape(t)}"]`;break}}if(["input","button","textarea","select","option"].includes(r)){e.getAttribute("type")&&(n=`${n}[type="${CSS.escape(e.getAttribute("type"))}"]`),e.getAttribute("name")&&(n=`${n}[name="${CSS.escape(e.getAttribute("name"))}"]`);const t=e.closest("form");if(t){let e="form";t.getAttribute("id")&&(e=`${e}#${CSS.escape(t.getAttribute("id"))}`),n=`${e} ${n}`}}const i=e.getAttribute("aria-label");if(i&&!o&&(n=`${n}[aria-label="${CSS.escape(i)}"]`),n){const t=e.closest("body");if(t)try{1!==t.querySelectorAll(n).length&&(n="")}catch(e){n=""}}}catch(e){}return n}function E(e,t){let n,r=e,o=[];for(;r;){let e=0,n=r.previousElementSibling;for(;n;)n.nodeName===r.nodeName&&e++,n=n.previousElementSibling;let i=r.nodeName.toLowerCase();e>0&&(i=i+"["+(e+1)+"]"),r!==t&&o.unshift(i),r=r.parentNode}if(n="/"+o.join("/"),function(e,t){const n=t.evaluate(e,t,null,XPathResult.ANY_TYPE,null),r=n.iterateNext();return r}(n,t)===e)return n}const S={},C={keydown:null,return:null,blur:null,change:null,click:null,dblclick:null,contextmenu:null,focus:null,mouseover:null,mouseout:null};let $=!1;function A(e,t){let n;var r;let o,i;function l(e,t,r){let i=null;const l=[];let s=e,c=0;for(;s&&s!==o.root.parentElement;){let e=w(f(s))||w(...d(s))||w(...m(s))||w(h(s))||[{name:"*",penalty:3}];const u=p(s);if(t===n.All)u&&(e=e.concat(e.filter(y).map((e=>g(e,u)))));else if(t===n.Two)e=e.slice(0,1),u&&(e=e.concat(e.filter(y).map((e=>g(e,u)))));else if(t===n.One){const[t]=e=e.slice(0,1);u&&y(t)&&(e=[g(t,u)])}for(const t of e)t.level=c;if(l.push(e),l.length>=o.seedMinLength&&(i=a(l,r),i))break;s=s.parentElement,c++}return i||(i=a(l,r)),i}function a(e,t){const n=N(v(e));if(n.length>o.threshold)return t?t():null;for(const e of n)if(u(e))return e;return null}function s(e){let t=e[0],n=t.name;for(let r=1;r ${n}`:`${e[r].name} ${n}`,t=e[r]}return n}function c(e){return e.map((e=>e.penalty)).reduce(((e,t)=>e+t),0)}function u(e){switch(i.querySelectorAll(s(e)).length){case 0:throw new Error(`Can't select any node with this selector: ${s(e)}`);case 1:return!0;default:return!1}}function f(e){const t=e.getAttribute("id");return t&&o.idName(t)?{name:`#${L(t,{isIdentifier:!0})}`,penalty:0}:null}function d(e){return Array.from(e.attributes).filter((e=>o.attr(e.name,e.value))).map((e=>({name:"["+L(e.name,{isIdentifier:!0})+'="'+L(e.value)+'"]',penalty:.5})))}function m(e){return Array.from(e.classList).filter(o.className).map((e=>({name:"."+L(e,{isIdentifier:!0}),penalty:1})))}function h(e){const t=e.tagName.toLowerCase();return o.tagName(t)?{name:t,penalty:2}:null}function p(e){const t=e.parentNode;if(!t)return null;let n=t.firstChild;if(!n)return null;let r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}function g(e,t){return{name:e.name+`:nth-child(${t})`,penalty:e.penalty+1}}function y(e){return"html"!==e.name&&!e.name.startsWith("#")}function w(...e){const t=e.filter(b);return 0c(e)-c(t)))}function E(e,t){return i.querySelector(s(e))===t}(r=n||(n={}))[r.All=0]="All",r[r.Two=1]="Two",r[r.One=2]="One";const S=/[ -,\.\/:-@\[-\^`\{-~]/,C=/[ -,\.\/:-@\[\]\^`\{-~]/,$=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,A={escapeEverything:!1,isIdentifier:!1,quotes:"single",wrap:!1};function L(e,t={}){const n=Object.assign(Object.assign({},A),t);"single"!==n.quotes&&"double"!==n.quotes&&(n.quotes="single");const r="double"==n.quotes?'"':"'",o=n.isIdentifier,i=e.charAt(0);let l="",a=0;for(const t=e.length;ac||126=c&&a!0,className:()=>!0,tagName:()=>!0,attr:()=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4};o=Object.assign(Object.assign({},T),t),i=function(e,t){return e.nodeType===Node.DOCUMENT_NODE?e:e===t.root?e.ownerDocument:e}(o.root,T);let x=l(e,n.All,(()=>l(e,n.Two,(()=>l(e,n.One)))));if(x){const t=N(function*e(t,n,r={counter:0,visited:new Map}){if(2o.optimizedMinLength)for(let i=1;io.maxNumberOfTries)return;r.counter+=1;const l=[...t];l.splice(i,1);const a=s(l);if(r.visited.has(a))return;u(l)&&E(l,n)&&(yield l,r.visited.set(a,!0),yield*e(l,n,r))}}(x,e));return 0{if(!i.isRecording)return;let l=!1,a=null;function s(e){e&&"mouseover"===e.type&&!l||function(e,t,r,o){let i=!1,l=null,a=null;e&&e.composed&&e.composedPath&&(a=e.composedPath());let s=-1;a&&a.length>0&&(s=a.findIndex((e=>e instanceof ShadowRoot))),l=s>-1?a[0]:e.target;const c=e.type;let u=null,f=null;if(!l||!l.getAttribute)return;u=l.nodeName.toLowerCase(),f=l.getAttribute("type");let d=null,m=null;try{m=function(e){let t=null;try{if(t=e.nodeName&&"string"==typeof e.nodeName?e.nodeName.toLowerCase():null,!t)return e;if(["input","button","a","textarea","select","option","progress"].includes(t))return e;const n=e.closest("button,a");if(n)return n;const r=e.closest("svg");r&&(e=r);const o=["data-test-id","data-testid","data-test","data-cy"];if(e.matches(o.map((e=>`[${e}]`)).join(",")))return e;if(e.parentNode.matches(o.map((e=>`[${e}]`)).join(",")))return e.parentNode}catch(e){}return e}(l),d=N(m)}catch(e){}if(!d)try{d=n(m,{root:t,idName:e=>!/^[0-9]+.*/i.test(e),className:e=>!e.includes("focus")&&!e.includes("highlight")&&!/^[0-9]+.*/i.test(e)})}catch(e){}if(d&&"html"===d.toLowerCase())return;let h=null;try{h=E(m,t)}catch(e){}s>-1&&(h="/html/node/shadow");let p={timestamp:(new Date).getTime(),css:d||l,xpath:h||""},g={};if("click"===c){if(C.click=l,!(C.return!==C.change||l===C.return||"input"!==u&&"button"!==u||"submit"!==f&&"image"!==f||null===C.return))return;if("input"===u&&("checkbox"===f||"radio"===f))return;if("label"===u){const e=l.getAttribute("for");if(e&&document.getElementById(e))return}let o="click";if("canvas"===u){const t=l.getBoundingClientRect(),n={x:e.clientX-t.left,y:e.clientY-t.top,width:t.width,height:t.height};p={...p,coords:n},o="bclick"}if(g={...p,type:o,value:(l.value||l.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r},"bclick"===o&&s>-1&&a){const e=a[s].host;if(e){let r=null;try{r=N(e)}catch(e){}if(!r)try{r=n(e,{root:t,idName:e=>!/^[0-9]+.*/i.test(e),className:e=>!e.includes("focus")&&!e.includes("highlight")&&!/^[0-9]+.*/i.test(e)})}catch(e){}r&&(g.shadow_host_css=r)}}}else if("dblclick"===c)C.dblclick=l,g={...p,type:"dblclick",value:(l.value||l.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r};else if("contextmenu"===c)C.contextmenu=l,g={...p,type:"contextmenu",value:(l.value||l.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r};else if("focus"===c);else if("mouseover"===c)$&&(clearTimeout($),$=!1),$=setTimeout((()=>{$=!1,C.mouseover=l,g={...p,type:"mouseover",value:(l.value||l.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r},g&&g.type&&o&&o({messageType:"events",event:{...g}})}),500);else if("mouseout"===c);else if("keydown"===c)C.keydown=l,["input","textarea"].indexOf(u)>-1&&(S[l]=l.value),"input"===u&&13===e.keyCode&&(i=!0,C.return=l,g={...p,type:"fill_value",value:l.value,frame:r});else if("blur"===c){if(C.blur=l,["input","textarea"].indexOf(u)>-1){if(S[l]=l.value,l===C.return)return void(C.return=null);if("input"===u&&("submit"===l.type||"button"===l.type||"image"===l.type))return;g={...p,type:"fill_value",value:l.value,frame:r}}}else if("change"===c)if(C.change=l,"input"===u)"checkbox"!==f&&"radio"!==f||(g={...p,type:"change",subtype:"check",checked:l.checked,frame:r});else if("select"===u)if(l.multiple){const e=[];for(let t=0;t{window!==window.top?window.parent.postMessage({source:"event-from-iframe",obj:{...e},framePath:[]},"*"):chrome.runtime.sendMessage(e)}))}window===window.top&&window.addEventListener("message",(e=>{if(e.data&&e.data.source&&"event-from-iframe"===e.data.source){const t=document.querySelectorAll("iframe, frame");let n=!1;for(const r of t)if(r.contentWindow===e.source){n=!0;break}if(!n)return;const r={...e.data.obj},o=e.data.framePath||[];for(const n of t)if(n.contentWindow===e.source){let e=null;try{e=N(n)}catch(e){}if(!e)try{e=A(n,{root:window.document,idName:e=>!/^[0-9]+.*/i.test(e),className:e=>!e.includes("focus")&&!e.includes("highlight")&&!/^[0-9]+.*/i.test(e)})}catch(e){}if(e&&r.event){const t=[e,...o];r.event.frame=t.join(" >>> "),chrome.runtime.sendMessage(r)}break}}})),window!==window.top&&window.addEventListener("message",(e=>{if(e.data&&e.data.source&&"event-from-iframe"===e.data.source){const t=document.querySelectorAll("iframe, frame");let n=!1;for(const r of t)if(r.contentWindow===e.source){n=!0;break}if(!n)return;const r=e.data.framePath||[];for(const n of t)if(n.contentWindow===e.source){let t=null;try{t=N(n)}catch(e){}if(!t)try{t=A(n,{root:window.document,idName:e=>!/^[0-9]+.*/i.test(e),className:e=>!e.includes("focus")&&!e.includes("highlight")&&!/^[0-9]+.*/i.test(e)})}catch(e){}t&&r.push(t),window.parent.postMessage({source:"event-from-iframe",obj:e.data.obj,framePath:r},"*");break}}})),i.isRecording&&(t=!0,e=document.title,function(){if(!t)return document.title=`${e}`,o=!1,void(r&&(clearInterval(r),r=!1));r=setInterval((()=>{o?(document.title=`${e}`,o=!1):(document.title=`🔴 ${e}`,o=!0)}),1e3)}(),window===window.top&&chrome.runtime.sendMessage({messageType:"events",event:{type:"goto",timestamp:(new Date).getTime(),windowWidth:window.innerWidth,windowHeight:window.innerHeight,url:window.location.href}}),document.addEventListener("click",s,!0),document.addEventListener("mouseover",s,!0),document.addEventListener("dblclick",s,!0),document.addEventListener("contextmenu",s,!0),document.addEventListener("keydown",s,!0),document.addEventListener("blur",s,!0),document.addEventListener("change",s,!0));const c={attributes:!1,childList:!0,subtree:!0},u=new MutationObserver((async(e,t)=>{l=!0,a&&(clearTimeout(a),a=null),a=setTimeout((()=>{l=!1}),200)}));document.body&&u.observe(document.body,c)}))}()})(); \ No newline at end of file diff --git a/test-build-firefox/manifest.json b/test-build-firefox/manifest.json index 4e66bc9..4660825 100644 --- a/test-build-firefox/manifest.json +++ b/test-build-firefox/manifest.json @@ -1,6 +1,6 @@ { "name": "Snyk API & Web Sequence Recorder", - "version": "1.0.0", + "version": "1.1.0", "browser_specific_settings": { "gecko": { "id": "sequence-recorder@probely.com", diff --git a/test-build-firefox/reviewpage.bundle.js b/test-build-firefox/reviewpage.bundle.js index 2bf2dbb..59fff4f 100644 --- a/test-build-firefox/reviewpage.bundle.js +++ b/test-build-firefox/reviewpage.bundle.js @@ -27,4 +27,4 @@ var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),l=Symbol.for("rea * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -function n(e,t){var n=e.length;e.push(t);e:for(;0>>1,l=e[r];if(!(0>>1;ra(i,n))sa(c,i)?(e[r]=c,e[s]=n,r=s):(e[r]=i,e[u]=n,r=u);else{if(!(sa(c,n)))break e;e[r]=c,e[s]=n,r=s}}}return t}function a(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;t.unstable_now=function(){return o.now()}}else{var u=Date,i=u.now();t.unstable_now=function(){return u.now()-i}}var s=[],c=[],f=1,d=null,p=3,m=!1,h=!1,g=!1,v="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,b="undefined"!=typeof setImmediate?setImmediate:null;function k(e){for(var t=r(c);null!==t;){if(null===t.callback)l(c);else{if(!(t.startTime<=e))break;l(c),t.sortIndex=t.expirationTime,n(s,t)}t=r(c)}}function w(e){if(g=!1,k(e),!h)if(null!==r(s))h=!0,O(S);else{var t=r(c);null!==t&&R(w,t.startTime-e)}}function S(e,n){h=!1,g&&(g=!1,y(C),C=-1),m=!0;var a=p;try{for(k(n),d=r(s);null!==d&&(!(d.expirationTime>n)||e&&!z());){var o=d.callback;if("function"==typeof o){d.callback=null,p=d.priorityLevel;var u=o(d.expirationTime<=n);n=t.unstable_now(),"function"==typeof u?d.callback=u:d===r(s)&&l(s),k(n)}else l(s);d=r(s)}if(null!==d)var i=!0;else{var f=r(c);null!==f&&R(w,f.startTime-n),i=!1}return i}finally{d=null,p=a,m=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var x,E=!1,_=null,C=-1,N=5,P=-1;function z(){return!(t.unstable_now()-Pe||125o?(e.sortIndex=a,n(c,e),null===r(s)&&e===r(c)&&(g?(y(C),C=-1):g=!0,R(w,a-o))):(e.sortIndex=u,n(s,e),h||m||(h=!0,O(S))),e},t.unstable_shouldYield=z,t.unstable_wrapCallback=function(e){var t=p;return function(){var n=p;p=t;try{return e.apply(this,arguments)}finally{p=n}}}},982:(e,t,n)=>{e.exports=n(463)},72:e=>{var t=[];function n(e){for(var n=-1,r=0;r{var t={};e.exports=function(e,n){var r=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},159:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56:(e,t,n)=>{e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},825:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var l=void 0!==n.layer;l&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,l&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var a=n.sourceMap;a&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function n(r){var l=t[r];if(void 0!==l)return l.exports;var a=t[r]={id:r,exports:{}};return e[r](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.p="/",n.nc=void 0;var r=n(540),l=n(961);const a=n.p+"adc8b34de96d4007231c.svg";let o=!1;const u=e=>{const[t,n]=(0,r.useState)([]),[l,u]=(0,r.useState)([]),[i,s]=(0,r.useState)([]),[c,f]=(0,r.useState)({status:!1,error:!1,msg:"Successfully copied to clipboard"}),[d,p]=(0,r.useState)(!0);function m(e){const t=JSON.parse(JSON.stringify(e)),n=[];t.forEach((e=>{e.opt.checked&&("goto"===e.type&&(e.urlType=e.opt.urlType),delete e.opt,n.push(e))})),s(n)}function h(e,t,n){if(-1===["css","fill_value"].indexOf(n))return;const r=JSON.parse(JSON.stringify(l));"css"===n?(r[t].opt.cssEditMode=!0,r[t].opt.cssOldValue=r[t].css):"fill_value"===n&&(r[t].opt.fillValueEditMode=!0,r[t].opt.fillValueOldValue=r[t].value),u(r),m(r)}function g(e,t,n){if(-1===["css","fill_value"].indexOf(n))return;const r=e.target,a=JSON.parse(JSON.stringify(l));"css"===n?a[t].css=r.value:"fill_value"===n&&(a[t].value=r.value),u(a),m(a)}function v(e,t,n){if(-1===["css","fill_value"].indexOf(n))return;const r=JSON.parse(JSON.stringify(l));"css"===n?(r[t].css=r[t].opt.cssOldValue,r[t].opt.cssEditMode=!1):"fill_value"===n&&(r[t].value=r[t].opt.fillValueOldValue,r[t].opt.fillValueEditMode=!1),u(r),m(r)}function y(e,t,n){if(e.preventDefault(),-1===["css","fill_value"].indexOf(n))return;const r=JSON.parse(JSON.stringify(l));"css"===n?r[t].opt.cssEditMode=!1:"fill_value"===n&&(r[t].opt.fillValueEditMode=!1),u(r),m(r)}return(0,r.useEffect)((()=>{chrome.runtime.onMessage.addListener(((e,t,r)=>{if("recording_data"===e.messageType&&!o){o=!0,n(e.recordingData||[]);const t=[].concat(e.recordingData).map(((e,t)=>(e.opt={},e.opt.checked=!0,"goto"===e.type&&(0===t?(e.opt.urlType="force",e.opt.urlDisabled=!0):(e.opt.urlType="ignore",e.opt.urlDisabled=!1)),e)));u(t),m(t)}})),chrome.runtime.sendMessage({messageType:"give_recording_data"})}),[]),r.createElement("div",{className:"App"},r.createElement("header",{className:"instructions"},r.createElement("div",{className:"header"},r.createElement("img",{src:a,alt:"Snyk API & Web"}),r.createElement("h1",null,"Sequence Recorder"))),r.createElement("div",{className:"main"},l&&l.length?r.createElement(r.Fragment,null,r.createElement("p",null,"You can copy or download the recorded information here or through the plugin window."),r.createElement("div",{className:"buttons-container"},r.createElement("button",{type:"button",className:"App-button",onClick:()=>{!function(){const e=document.getElementById("input-copy-to-clipboard");if(e){e.select();const t=e.value;let n=!1;try{n=document.execCommand("copy")}catch(e){try{window.clipboardData.setData("text",t),n=!0}catch(e){}}n?(f({status:!0,error:!1,msg:"Successfully copied to clipboard"}),setTimeout((()=>{f({status:!1,error:!1,msg:""})}),3e3)):(f({status:!0,error:!0,msg:"Error on copy to clipboard"}),setTimeout((()=>{f({status:!1,error:!1,msg:""})}),5e3))}}()}},"Copy to clipboard"),r.createElement("button",{type:"button",className:"App-button",onClick:()=>{!function(){let e=null;if(e=new Blob([JSON.stringify(i,null,2)],{type:"text/plain;charset=utf-8"}),!e)return;const t=document.createElement("a");t.download="snyk-api-and-web-recording.json",t.rel="noopener",t.href=URL.createObjectURL(e);try{t.dispatchEvent(new MouseEvent("click"))}catch(e){const n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(n)}}()}},"Download")),r.createElement("div",{className:"advance_check_container"},r.createElement("input",{type:"checkbox",id:"review_advanced_options",value:"1",className:"form-control input_custom",checked:d,onChange:e=>{!function(e){e.target.checked?p(!0):p(!1)}(e)}}),r.createElement("label",{htmlFor:"review_advanced_options",className:"review_advanced_options_text"},"Advanced options")),r.createElement("p",null,"After saving your sequence, make sure to import it to your target settings at Snyk API & Web, so it is followed during scans.")):r.createElement("h3",null,r.createElement("strong",null,"No data has been recorded")),r.createElement("div",{className:"copy-status-container"},c.status?r.createElement("div",{className:c.error?"copy-status error":"copy-status success"},c.msg):null),l&&l.length&&d?r.createElement(r.Fragment,null,r.createElement("div",{className:"advanced_instructions"},r.createElement("p",{className:"center"},"You can review the steps recorded below."," ","Note that changing the sequence in any way could prevent the crawler from successfully replaying it."),r.createElement("p",null,"Some tips:"),r.createElement("ul",null,r.createElement("li",null,"You can edit the CSS selectors (click on the CSS selector) to adjust some possible variable selectors."," ",'For instance for the selector "',r.createElement("code",null,r.createElement("b",null,"#foo > .nav-item.item_42")),'" where "42" is an ID,'," ",'using "',r.createElement("code",null,r.createElement("b",null,".item_42")),'" is not recomended.'),r.createElement("li",null,'You can edit "',r.createElement("b",null,"fill with value"),'" values (click on the text value) to use random values. For instance, in a registration form where the email needs to be unique,'," ","you can use the value ",r.createElement("code",null,"email+",r.createElement("b",null,"{RAND_STRING}"),"@example.com"),".",r.createElement("br",null),"Possible values:",r.createElement("ul",null,r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_STRING}"))," - random string"),r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_STRING[5]}"))," - random string with length X (e.g. 5)"),r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_NUMBER}"))," - random number"),r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_NUMBER[10-99]}"))," - random number between X and Y (e.g. 10 and 99)"))))),r.createElement("table",{className:"review_table"},r.createElement("thead",null,r.createElement("tr",null,r.createElement("th",{className:"table_id"}),r.createElement("th",{className:"table_type"}),r.createElement("th",{className:"table_selector"}),r.createElement("th",{className:"table_value"}))),r.createElement("tbody",null,l.map(((e,t)=>r.createElement("tr",{className:"table_tr "+(t%2==0?"odd":"even"),key:`item_${t}`},r.createElement("td",null,r.createElement("input",{type:"checkbox",name:`item_name_${t}`,value:t,disabled:0===t,checked:e.opt.checked,className:"t_line_checkbox",onChange:e=>{!function(e,t){const n=e.target,r=JSON.parse(JSON.stringify(l));r[t].opt.checked=!!n.checked,u(r),m(r)}(e,t)}})),r.createElement("td",null,r.createElement("span",{className:"t_item_type "},function(e){let t=e;switch(e){case"fill_value":t="fill with value";break;case"press_key":t="press [ENTER]";break;case"goto":t="go to";break;default:t=e}return t}(e.type))),r.createElement("td",null,"goto"===e.type?r.createElement("span",{className:"t_url"},e.url):e.opt.cssEditMode?r.createElement("form",{method:"post",action:"",onSubmit:e=>{y(e,t,"css")}},r.createElement("input",{type:"text",className:"t_selector_input",value:e.css,onChange:e=>{g(e,t,"css")}}),r.createElement("button",{type:"submit",className:"t_btn_ok"},"Save"),r.createElement("button",{type:"button",className:"t_btn_cancel",onClick:e=>{v(0,t,"css")}},"Cancel")):r.createElement("span",{className:"t_selector",onClick:e=>{h(0,t,"css")}},e.css)),r.createElement("td",null,"fill_value"===e.type?e.opt.fillValueEditMode?r.createElement("form",{method:"post",action:"",onSubmit:e=>{y(e,t,"fill_value")}},r.createElement("input",{type:"text",className:"t_fill_value_input",value:e.value,onChange:e=>{g(e,t,"fill_value")}}),r.createElement("button",{type:"submit",className:"t_btn_ok"},"Save"),r.createElement("button",{type:"button",className:"t_btn_cancel",onClick:e=>{v(0,t,"fill_value")}},"Cancel")):r.createElement("span",{className:"t_selector",onClick:e=>{h(0,t,"fill_value")}},e.value):null,"change"===e.type&&"check"===e.subtype?e.checked?"checked":"not checked":null,"change"===e.type&&"select"===e.subtype?`index ${e.selected}`:null,"goto"===e.type?r.createElement("span",null,"Navigate to URL"):null))))))):null),r.createElement("div",null),l.length?r.createElement("textarea",{id:"input-copy-to-clipboard",readOnly:!0,value:JSON.stringify(i,null,2)}):null)};var i=n(72),s=n.n(i),c=n(825),f=n.n(c),d=n(659),p=n.n(d),m=n(56),h=n.n(m),g=n(159),v=n.n(g),y=n(113),b=n.n(y),k=n(639),w={};w.styleTagTransform=b(),w.setAttributes=h(),w.insert=p().bind(null,"head"),w.domAPI=f(),w.insertStyleElement=v();s()(k.A,w);k.A&&k.A.locals&&k.A.locals;(0,l.render)(r.createElement(u,null),window.document.querySelector("#app-container"))})(); \ No newline at end of file +function n(e,t){var n=e.length;e.push(t);e:for(;0>>1,l=e[r];if(!(0>>1;ra(i,n))sa(c,i)?(e[r]=c,e[s]=n,r=s):(e[r]=i,e[u]=n,r=u);else{if(!(sa(c,n)))break e;e[r]=c,e[s]=n,r=s}}}return t}function a(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;t.unstable_now=function(){return o.now()}}else{var u=Date,i=u.now();t.unstable_now=function(){return u.now()-i}}var s=[],c=[],f=1,d=null,p=3,m=!1,h=!1,g=!1,v="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,b="undefined"!=typeof setImmediate?setImmediate:null;function k(e){for(var t=r(c);null!==t;){if(null===t.callback)l(c);else{if(!(t.startTime<=e))break;l(c),t.sortIndex=t.expirationTime,n(s,t)}t=r(c)}}function w(e){if(g=!1,k(e),!h)if(null!==r(s))h=!0,O(S);else{var t=r(c);null!==t&&R(w,t.startTime-e)}}function S(e,n){h=!1,g&&(g=!1,y(C),C=-1),m=!0;var a=p;try{for(k(n),d=r(s);null!==d&&(!(d.expirationTime>n)||e&&!z());){var o=d.callback;if("function"==typeof o){d.callback=null,p=d.priorityLevel;var u=o(d.expirationTime<=n);n=t.unstable_now(),"function"==typeof u?d.callback=u:d===r(s)&&l(s),k(n)}else l(s);d=r(s)}if(null!==d)var i=!0;else{var f=r(c);null!==f&&R(w,f.startTime-n),i=!1}return i}finally{d=null,p=a,m=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var x,E=!1,_=null,C=-1,N=5,P=-1;function z(){return!(t.unstable_now()-Pe||125o?(e.sortIndex=a,n(c,e),null===r(s)&&e===r(c)&&(g?(y(C),C=-1):g=!0,R(w,a-o))):(e.sortIndex=u,n(s,e),h||m||(h=!0,O(S))),e},t.unstable_shouldYield=z,t.unstable_wrapCallback=function(e){var t=p;return function(){var n=p;p=t;try{return e.apply(this,arguments)}finally{p=n}}}},982:(e,t,n)=>{e.exports=n(463)},72:e=>{var t=[];function n(e){for(var n=-1,r=0;r{var t={};e.exports=function(e,n){var r=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},159:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56:(e,t,n)=>{e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},825:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var l=void 0!==n.layer;l&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,l&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var a=n.sourceMap;a&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function n(r){var l=t[r];if(void 0!==l)return l.exports;var a=t[r]={id:r,exports:{}};return e[r](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.p="/",n.nc=void 0;var r=n(540),l=n(961);const a=n.p+"adc8b34de96d4007231c.svg";let o=!1;const u=e=>{const[t,n]=(0,r.useState)([]),[l,u]=(0,r.useState)([]),[i,s]=(0,r.useState)([]),[c,f]=(0,r.useState)({status:!1,error:!1,msg:"Successfully copied to clipboard"}),[d,p]=(0,r.useState)(!0);function m(e){const t=JSON.parse(JSON.stringify(e)),n=[];t.forEach((e=>{e.opt.checked&&("goto"===e.type&&(e.urlType=e.opt.urlType),delete e.opt,n.push(e))})),s(n)}function h(e,t,n){if(-1===["css","fill_value"].indexOf(n))return;const r=JSON.parse(JSON.stringify(l));"css"===n?(r[t].opt.cssEditMode=!0,r[t].opt.cssOldValue=r[t].css):"fill_value"===n&&(r[t].opt.fillValueEditMode=!0,r[t].opt.fillValueOldValue=r[t].value),u(r),m(r)}function g(e,t,n){if(-1===["css","fill_value"].indexOf(n))return;const r=e.target,a=JSON.parse(JSON.stringify(l));"css"===n?a[t].css=r.value:"fill_value"===n&&(a[t].value=r.value),u(a),m(a)}function v(e,t,n){if(-1===["css","fill_value"].indexOf(n))return;const r=JSON.parse(JSON.stringify(l));"css"===n?(r[t].css=r[t].opt.cssOldValue,r[t].opt.cssEditMode=!1):"fill_value"===n&&(r[t].value=r[t].opt.fillValueOldValue,r[t].opt.fillValueEditMode=!1),u(r),m(r)}function y(e,t,n){if(e.preventDefault(),-1===["css","fill_value"].indexOf(n))return;const r=JSON.parse(JSON.stringify(l));"css"===n?r[t].opt.cssEditMode=!1:"fill_value"===n&&(r[t].opt.fillValueEditMode=!1),u(r),m(r)}return(0,r.useEffect)((()=>{chrome.runtime.onMessage.addListener(((e,t,r)=>{if("recording_data"===e.messageType&&!o){o=!0,n(e.recordingData||[]);const t=[].concat(e.recordingData).map(((e,t)=>(e.opt={},e.opt.checked=!0,"goto"===e.type&&(0===t?(e.opt.urlType="force",e.opt.urlDisabled=!0):(e.opt.urlType="ignore",e.opt.urlDisabled=!1)),e)));u(t),m(t)}})),chrome.runtime.sendMessage({messageType:"give_recording_data"})}),[]),r.createElement("div",{className:"App"},r.createElement("header",{className:"instructions"},r.createElement("div",{className:"header"},r.createElement("img",{src:a,alt:"Snyk API & Web"}),r.createElement("h1",null,"Sequence Recorder"))),r.createElement("div",{className:"main"},l&&l.length?r.createElement(r.Fragment,null,r.createElement("p",null,"You can copy or download the recorded information here or through the plugin window."),r.createElement("div",{className:"buttons-container"},r.createElement("button",{type:"button",className:"App-button",onClick:()=>{!function(){const e=document.getElementById("input-copy-to-clipboard");if(e){e.select();const t=e.value;let n=!1;try{n=document.execCommand("copy")}catch(e){try{window.clipboardData.setData("text",t),n=!0}catch(e){}}n?(f({status:!0,error:!1,msg:"Successfully copied to clipboard"}),setTimeout((()=>{f({status:!1,error:!1,msg:""})}),3e3)):(f({status:!0,error:!0,msg:"Error on copy to clipboard"}),setTimeout((()=>{f({status:!1,error:!1,msg:""})}),5e3))}}()}},"Copy to clipboard"),r.createElement("button",{type:"button",className:"App-button",onClick:()=>{!function(){let e=null;if(e=new Blob([JSON.stringify(i,null,2)],{type:"text/plain;charset=utf-8"}),!e)return;const t=document.createElement("a");t.download="snyk-api-and-web-recording.json",t.rel="noopener",t.href=URL.createObjectURL(e);try{t.dispatchEvent(new MouseEvent("click"))}catch(e){const n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(n)}}()}},"Download")),r.createElement("div",{className:"advance_check_container"},r.createElement("input",{type:"checkbox",id:"review_advanced_options",value:"1",className:"form-control input_custom",checked:d,onChange:e=>{!function(e){e.target.checked?p(!0):p(!1)}(e)}}),r.createElement("label",{htmlFor:"review_advanced_options",className:"review_advanced_options_text"},"Advanced options")),r.createElement("p",null,"After saving your sequence, make sure to import it to your target settings at Snyk API & Web, so it is followed during scans.")):r.createElement("h3",null,r.createElement("strong",null,"No data has been recorded")),r.createElement("div",{className:"copy-status-container"},c.status?r.createElement("div",{className:c.error?"copy-status error":"copy-status success"},c.msg):null),l&&l.length&&d?r.createElement(r.Fragment,null,r.createElement("div",{className:"advanced_instructions"},r.createElement("p",{className:"center"},"You can review the steps recorded below."," ","Note that changing the sequence in any way could prevent the crawler from successfully replaying it."),r.createElement("p",null,"Some tips:"),r.createElement("ul",null,r.createElement("li",null,"You can edit the CSS selectors (click on the CSS selector) to adjust some possible variable selectors."," ",'For instance for the selector "',r.createElement("code",null,r.createElement("b",null,"#foo > .nav-item.item_42")),'" where "42" is an ID,'," ",'using "',r.createElement("code",null,r.createElement("b",null,".item_42")),'" is not recomended.'),r.createElement("li",null,'You can edit "',r.createElement("b",null,"fill with value"),'" values (click on the text value) to use random values. For instance, in a registration form where the email needs to be unique,'," ","you can use the value ",r.createElement("code",null,"email+",r.createElement("b",null,"{RAND_STRING}"),"@example.com"),".",r.createElement("br",null),"Possible values:",r.createElement("ul",null,r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_STRING}"))," - random string"),r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_STRING[5]}"))," - random string with length X (e.g. 5)"),r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_NUMBER}"))," - random number"),r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_NUMBER[10-99]}"))," - random number between X and Y (e.g. 10 and 99)"))))),r.createElement("table",{className:"review_table"},r.createElement("thead",null,r.createElement("tr",null,r.createElement("th",{className:"table_id"}),r.createElement("th",{className:"table_type"}),r.createElement("th",{className:"table_selector"}),r.createElement("th",{className:"table_value"}))),r.createElement("tbody",null,l.map(((e,t)=>r.createElement("tr",{className:"table_tr "+(t%2==0?"odd":"even"),key:`item_${t}`},r.createElement("td",null,r.createElement("input",{type:"checkbox",name:`item_name_${t}`,value:t,disabled:0===t,checked:e.opt.checked,className:"t_line_checkbox",onChange:e=>{!function(e,t){const n=e.target,r=JSON.parse(JSON.stringify(l));r[t].opt.checked=!!n.checked,u(r),m(r)}(e,t)}})),r.createElement("td",null,r.createElement("span",{className:"t_item_type "},function(e){let t=e;switch(e){case"fill_value":t="fill with value";break;case"press_key":t="press [ENTER]";break;case"goto":t="go to";break;case"click":case"bclick":t="click";break;default:t=e}return t}(e.type))),r.createElement("td",null,"goto"===e.type?r.createElement("span",{className:"t_url"},e.url):e.opt.cssEditMode?r.createElement("form",{method:"post",action:"",onSubmit:e=>{y(e,t,"css")}},r.createElement("input",{type:"text",className:"t_selector_input",value:e.css,onChange:e=>{g(e,t,"css")}}),r.createElement("button",{type:"submit",className:"t_btn_ok"},"Save"),r.createElement("button",{type:"button",className:"t_btn_cancel",onClick:e=>{v(0,t,"css")}},"Cancel")):r.createElement("span",{className:"t_selector",onClick:e=>{h(0,t,"css")}},e.css)),r.createElement("td",null,"fill_value"===e.type?e.opt.fillValueEditMode?r.createElement("form",{method:"post",action:"",onSubmit:e=>{y(e,t,"fill_value")}},r.createElement("input",{type:"text",className:"t_fill_value_input",value:e.value,onChange:e=>{g(e,t,"fill_value")}}),r.createElement("button",{type:"submit",className:"t_btn_ok"},"Save"),r.createElement("button",{type:"button",className:"t_btn_cancel",onClick:e=>{v(0,t,"fill_value")}},"Cancel")):r.createElement("span",{className:"t_selector",onClick:e=>{h(0,t,"fill_value")}},e.value):null,"change"===e.type&&"check"===e.subtype?e.checked?"checked":"not checked":null,"change"===e.type&&"select"===e.subtype?`index ${e.selected}`:null,"goto"===e.type?r.createElement("span",null,"Navigate to URL"):null))))))):null),r.createElement("div",null),l.length?r.createElement("textarea",{id:"input-copy-to-clipboard",readOnly:!0,value:JSON.stringify(i,null,2)}):null)};var i=n(72),s=n.n(i),c=n(825),f=n.n(c),d=n(659),p=n.n(d),m=n(56),h=n.n(m),g=n(159),v=n.n(g),y=n(113),b=n.n(y),k=n(639),w={};w.styleTagTransform=b(),w.setAttributes=h(),w.insert=p().bind(null,"head"),w.domAPI=f(),w.insertStyleElement=v();s()(k.A,w);k.A&&k.A.locals&&k.A.locals;(0,l.render)(r.createElement(u,null),window.document.querySelector("#app-container"))})(); \ No newline at end of file diff --git a/test-build/contentScript.bundle.js b/test-build/contentScript.bundle.js index 0f74816..c0943a6 100644 --- a/test-build/contentScript.bundle.js +++ b/test-build/contentScript.bundle.js @@ -1 +1 @@ -(()=>{"use strict";let e,t;function n(n,o){if(n.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===n.tagName.toLowerCase())return"html";const i={root:document.body,idName:e=>!0,className:e=>!0,tagName:e=>!0,attr:(e,t)=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4};e={...i,...o},t=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(e.root,i);let a=r(n,"all",(()=>r(n,"two",(()=>r(n,"one",(()=>r(n,"none")))))));if(a){const e=w(v(a,n));return e.length>0&&(a=e[0]),l(a)}throw new Error("Selector was not found.")}function r(t,n,r){let l=null,i=[],a=t,g=0;for(;a;){let t=h(u(a))||h(...s(a))||h(...c(a))||h(f(a))||[{name:"*",penalty:3}];const y=d(a);if("all"==n)y&&(t=t.concat(t.filter(p).map((e=>m(e,y)))));else if("two"==n)t=t.slice(0,1),y&&(t=t.concat(t.filter(p).map((e=>m(e,y)))));else if("one"==n){const[e]=t=t.slice(0,1);y&&p(e)&&(t=[m(e,y)])}else"none"==n&&(t=[{name:"*",penalty:3}],y&&(t=[m(t[0],y)]));for(let e of t)e.level=g;if(i.push(t),i.length>=e.seedMinLength&&(l=o(i,r),l))break;a=a.parentElement,g++}return l||(l=o(i,r)),!l&&r?r():l}function o(t,n){const r=w(y(t));if(r.length>e.threshold)return n?n():null;for(let e of r)if(a(e))return e;return null}function l(e){let t=e[0],n=t.name;for(let r=1;r ${n}`:`${e[r].name} ${n}`,t=e[r]}return n}function i(e){return e.map((e=>e.penalty)).reduce(((e,t)=>e+t),0)}function a(e){const n=l(e);switch(t.querySelectorAll(n).length){case 0:throw new Error(`Can't select any node with this selector: ${n}`);case 1:return!0;default:return!1}}function u(t){const n=t.getAttribute("id");return n&&e.idName(n)?{name:"#"+CSS.escape(n),penalty:0}:null}function s(t){const n=Array.from(t.attributes).filter((t=>e.attr(t.name,t.value)));return n.map((e=>({name:`[${CSS.escape(e.name)}="${CSS.escape(e.value)}"]`,penalty:.5})))}function c(t){return Array.from(t.classList).filter(e.className).map((e=>({name:"."+CSS.escape(e),penalty:1})))}function f(t){const n=t.tagName.toLowerCase();return e.tagName(n)?{name:n,penalty:2}:null}function d(e){const t=e.parentNode;if(!t)return null;let n=t.firstChild;if(!n)return null;let r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}function m(e,t){return{name:e.name+`:nth-child(${t})`,penalty:e.penalty+1}}function p(e){return"html"!==e.name&&!e.name.startsWith("#")}function h(...e){const t=e.filter(g);return t.length>0?t:null}function g(e){return null!=e}function*y(e,t=[]){if(e.length>0)for(let n of e[0])yield*y(e.slice(1,e.length),t.concat(n));else yield t}function w(e){return[...e].sort(((e,t)=>i(e)-i(t)))}function*v(t,n,r={counter:0,visited:new Map}){if(t.length>2&&t.length>e.optimizedMinLength)for(let o=1;oe.maxNumberOfTries)return;r.counter+=1;const i=[...t];i.splice(o,1);const u=l(i);if(r.visited.has(u))return;a(i)&&b(i,n)&&(yield i,r.visited.set(u,!0),yield*v(i,n,r))}}function b(e,n){return t.querySelector(l(e))===n}function N(e,t){let n="",r=null,o=!1;try{if(r=e.nodeName&&"string"==typeof e.nodeName?e.nodeName.toLowerCase():null,!r)return null;n=`${r}`,e.getAttribute("id")&&(n=`${n}#${CSS.escape(e.getAttribute("id"))}`,o=!0);const t=["data-test-id","data-testid","data-test","data-cy"];if(e.matches(t.map((e=>`[${e}]`)).join(",")))for(const r of t){const t=e.getAttribute(r);if(t){n=`${n}[${r}="${CSS.escape(t)}"]`;break}}if(["input","button","textarea","select","option"].includes(r)){e.getAttribute("type")&&(n=`${n}[type="${CSS.escape(e.getAttribute("type"))}"]`),e.getAttribute("name")&&(n=`${n}[name="${CSS.escape(e.getAttribute("name"))}"]`);const t=e.closest("form");if(t){let e="form";t.getAttribute("id")&&(e=`${e}#${CSS.escape(t.getAttribute("id"))}`),n=`${e} ${n}`}}const l=e.getAttribute("aria-label");if(l&&!o&&(n=`${n}[aria-label="${CSS.escape(l)}"]`),n){const t=e.closest("body");if(t)try{1!==t.querySelectorAll(n).length&&(n="")}catch(e){n=""}}}catch(e){}return n}function E(e,t){let n,r=e,o=[];for(;r;){let e=0,n=r.previousElementSibling;for(;n;)n.nodeName===r.nodeName&&e++,n=n.previousElementSibling;let l=r.nodeName.toLowerCase();e>0&&(l=l+"["+(e+1)+"]"),r!==t&&o.unshift(l),r=r.parentNode}if(n="/"+o.join("/"),function(e,t){const n=t.evaluate(e,t,null,XPathResult.ANY_TYPE,null),r=n.iterateNext();return r}(n,t)===e)return n}const S={},C={keydown:null,return:null,blur:null,change:null,click:null,dblclick:null,contextmenu:null,focus:null,mouseover:null,mouseout:null};let $=!1;function A(e,t){let n;var r;let o,l;function i(e,t,r){let l=null;const i=[];let u=e,s=0;for(;u&&u!==o.root.parentElement;){let e=w(f(u))||w(...d(u))||w(...m(u))||w(p(u))||[{name:"*",penalty:3}];const c=h(u);if(t===n.All)c&&(e=e.concat(e.filter(y).map((e=>g(e,c)))));else if(t===n.Two)e=e.slice(0,1),c&&(e=e.concat(e.filter(y).map((e=>g(e,c)))));else if(t===n.One){const[t]=e=e.slice(0,1);c&&y(t)&&(e=[g(t,c)])}for(const t of e)t.level=s;if(i.push(e),i.length>=o.seedMinLength&&(l=a(i,r),l))break;u=u.parentElement,s++}return l||(l=a(i,r)),l}function a(e,t){const n=N(b(e));if(n.length>o.threshold)return t?t():null;for(const e of n)if(c(e))return e;return null}function u(e){let t=e[0],n=t.name;for(let r=1;r ${n}`:`${e[r].name} ${n}`,t=e[r]}return n}function s(e){return e.map((e=>e.penalty)).reduce(((e,t)=>e+t),0)}function c(e){switch(l.querySelectorAll(u(e)).length){case 0:throw new Error(`Can't select any node with this selector: ${u(e)}`);case 1:return!0;default:return!1}}function f(e){const t=e.getAttribute("id");return t&&o.idName(t)?{name:`#${L(t,{isIdentifier:!0})}`,penalty:0}:null}function d(e){return Array.from(e.attributes).filter((e=>o.attr(e.name,e.value))).map((e=>({name:"["+L(e.name,{isIdentifier:!0})+'="'+L(e.value)+'"]',penalty:.5})))}function m(e){return Array.from(e.classList).filter(o.className).map((e=>({name:"."+L(e,{isIdentifier:!0}),penalty:1})))}function p(e){const t=e.tagName.toLowerCase();return o.tagName(t)?{name:t,penalty:2}:null}function h(e){const t=e.parentNode;if(!t)return null;let n=t.firstChild;if(!n)return null;let r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}function g(e,t){return{name:e.name+`:nth-child(${t})`,penalty:e.penalty+1}}function y(e){return"html"!==e.name&&!e.name.startsWith("#")}function w(...e){const t=e.filter(v);return 0s(e)-s(t)))}function E(e,t){return l.querySelector(u(e))===t}(r=n||(n={}))[r.All=0]="All",r[r.Two=1]="Two",r[r.One=2]="One";const S=/[ -,\.\/:-@\[-\^`\{-~]/,C=/[ -,\.\/:-@\[\]\^`\{-~]/,$=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,A={escapeEverything:!1,isIdentifier:!1,quotes:"single",wrap:!1};function L(e,t={}){const n=Object.assign(Object.assign({},A),t);"single"!==n.quotes&&"double"!==n.quotes&&(n.quotes="single");const r="double"==n.quotes?'"':"'",o=n.isIdentifier,l=e.charAt(0);let i="",a=0;for(const t=e.length;as||126=s&&a!0,className:()=>!0,tagName:()=>!0,attr:()=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4};o=Object.assign(Object.assign({},T),t),l=function(e,t){return e.nodeType===Node.DOCUMENT_NODE?e:e===t.root?e.ownerDocument:e}(o.root,T);let x=i(e,n.All,(()=>i(e,n.Two,(()=>i(e,n.One)))));if(x){const t=N(function*e(t,n,r={counter:0,visited:new Map}){if(2o.optimizedMinLength)for(let l=1;lo.maxNumberOfTries)return;r.counter+=1;const i=[...t];i.splice(l,1);const a=u(i);if(r.visited.has(a))return;c(i)&&E(i,n)&&(yield i,r.visited.set(a,!0),yield*e(i,n,r))}}(x,e));return 0{if(!l.isRecording)return;let i=!1,a=null;function u(e){e&&"mouseover"===e.type&&!i||function(e,t,r,o){let l=!1,i=null,a=null;e&&e.composed&&e.composedPath&&(a=e.composedPath());let u=-1;a&&a.length>0&&(u=a.findIndex((e=>e instanceof ShadowRoot))),i=u>-1?a[0]:e.target;const s=e.type;let c=null,f=null;if(!i||!i.getAttribute)return;c=i.nodeName.toLowerCase(),f=i.getAttribute("type");let d=null,m=null;try{m=function(e){let t=null;try{if(t=e.nodeName&&"string"==typeof e.nodeName?e.nodeName.toLowerCase():null,!t)return e;if(["input","button","a","textarea","select","option","progress"].includes(t))return e;const n=e.closest("button,a");if(n)return n;const r=e.closest("svg");r&&(e=r);const o=["data-test-id","data-testid","data-test","data-cy"];if(e.matches(o.map((e=>`[${e}]`)).join(",")))return e;if(e.parentNode.matches(o.map((e=>`[${e}]`)).join(",")))return e.parentNode}catch(e){}return e}(i),d=N(m)}catch(e){}if(!d)try{d=n(m,{root:t,idName:e=>!/^[0-9]+.*/i.test(e),className:e=>!e.includes("focus")&&!e.includes("highlight")&&!/^[0-9]+.*/i.test(e)})}catch(e){}if(d&&"html"===d.toLowerCase())return;let p=null;try{p=E(m,t)}catch(e){}u>-1&&(p="/html/node/shadow");let h={timestamp:(new Date).getTime(),css:d||i,xpath:p||""},g={};if("click"===s){if(C.click=i,!(C.return!==C.change||i===C.return||"input"!==c&&"button"!==c||"submit"!==f&&"image"!==f||null===C.return))return;if("input"===c&&("checkbox"===f||"radio"===f))return;if("label"===c){const e=i.getAttribute("for");if(e&&document.getElementById(e))return}g={...h,type:"click",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r}}else if("dblclick"===s)C.dblclick=i,g={...h,type:"dblclick",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r};else if("contextmenu"===s)C.contextmenu=i,g={...h,type:"contextmenu",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r};else if("focus"===s);else if("mouseover"===s)$&&(clearTimeout($),$=!1),$=setTimeout((()=>{$=!1,C.mouseover=i,g={...h,type:"mouseover",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r},g&&g.type&&o&&o({messageType:"events",event:{...g}})}),500);else if("mouseout"===s);else if("keydown"===s)C.keydown=i,["input","textarea"].indexOf(c)>-1&&(S[i]=i.value),"input"===c&&13===e.keyCode&&(l=!0,C.return=i,g={...h,type:"fill_value",value:i.value,frame:r});else if("blur"===s){if(C.blur=i,["input","textarea"].indexOf(c)>-1){if(S[i]=i.value,i===C.return)return void(C.return=null);if("input"===c&&("submit"===i.type||"button"===i.type||"image"===i.type))return;g={...h,type:"fill_value",value:i.value,frame:r}}}else if("change"===s)if(C.change=i,"input"===c)"checkbox"!==f&&"radio"!==f||(g={...h,type:"change",subtype:"check",checked:i.checked,frame:r});else if("select"===c)if(i.multiple){const e=[];for(let t=0;t{window!==window.top?window.parent.postMessage({source:"event-from-iframe",obj:{...e}},"*"):chrome.runtime.sendMessage(e)}))}window===window.top&&window.addEventListener("message",(e=>{if(e.data&&e.data.source&&"event-from-iframe"===e.data.source){const t={...e.data.obj},n=document.querySelectorAll("iframe, frame");for(const r of n)if(r.contentWindow===e.source){let e=null;try{e=N(r)}catch(e){}if(!e)try{e=A(r,{root:window.document,idName:e=>!/^[0-9]+.*/i.test(e),className:e=>!e.includes("focus")&&!e.includes("highlight")&&!/^[0-9]+.*/i.test(e)})}catch(e){}e&&t.event&&(t.event.frame=e,chrome.runtime.sendMessage(t));break}}})),l.isRecording&&(t=!0,e=document.title,function(){if(!t)return document.title=`${e}`,o=!1,void(r&&(clearInterval(r),r=!1));r=setInterval((()=>{o?(document.title=`${e}`,o=!1):(document.title=`🔴 ${e}`,o=!0)}),1e3)}(),window===window.top&&chrome.runtime.sendMessage({messageType:"events",event:{type:"goto",timestamp:(new Date).getTime(),windowWidth:window.innerWidth,windowHeight:window.innerHeight,url:window.location.href}}),document.addEventListener("click",u,!0),document.addEventListener("mouseover",u,!0),document.addEventListener("dblclick",u,!0),document.addEventListener("contextmenu",u,!0),document.addEventListener("keydown",u,!0),document.addEventListener("blur",u,!0),document.addEventListener("change",u,!0));const s={attributes:!1,childList:!0,subtree:!0},c=new MutationObserver((async(e,t)=>{i=!0,a&&(clearTimeout(a),a=null),a=setTimeout((()=>{i=!1}),200)}));document.body&&c.observe(document.body,s)}))}()})(); \ No newline at end of file +(()=>{"use strict";let e,t;function n(n,o){if(n.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===n.tagName.toLowerCase())return"html";const l={root:document.body,idName:e=>!0,className:e=>!0,tagName:e=>!0,attr:(e,t)=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4};e={...l,...o},t=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(e.root,l);let a=r(n,"all",(()=>r(n,"two",(()=>r(n,"one",(()=>r(n,"none")))))));if(a){const e=w(b(a,n));return e.length>0&&(a=e[0]),i(a)}throw new Error("Selector was not found.")}function r(t,n,r){let i=null,l=[],a=t,g=0;for(;a;){let t=p(s(a))||p(...c(a))||p(...u(a))||p(f(a))||[{name:"*",penalty:3}];const y=d(a);if("all"==n)y&&(t=t.concat(t.filter(h).map((e=>m(e,y)))));else if("two"==n)t=t.slice(0,1),y&&(t=t.concat(t.filter(h).map((e=>m(e,y)))));else if("one"==n){const[e]=t=t.slice(0,1);y&&h(e)&&(t=[m(e,y)])}else"none"==n&&(t=[{name:"*",penalty:3}],y&&(t=[m(t[0],y)]));for(let e of t)e.level=g;if(l.push(t),l.length>=e.seedMinLength&&(i=o(l,r),i))break;a=a.parentElement,g++}return i||(i=o(l,r)),!i&&r?r():i}function o(t,n){const r=w(y(t));if(r.length>e.threshold)return n?n():null;for(let e of r)if(a(e))return e;return null}function i(e){let t=e[0],n=t.name;for(let r=1;r ${n}`:`${e[r].name} ${n}`,t=e[r]}return n}function l(e){return e.map((e=>e.penalty)).reduce(((e,t)=>e+t),0)}function a(e){const n=i(e);switch(t.querySelectorAll(n).length){case 0:throw new Error(`Can't select any node with this selector: ${n}`);case 1:return!0;default:return!1}}function s(t){const n=t.getAttribute("id");return n&&e.idName(n)?{name:"#"+CSS.escape(n),penalty:0}:null}function c(t){const n=Array.from(t.attributes).filter((t=>e.attr(t.name,t.value)));return n.map((e=>({name:`[${CSS.escape(e.name)}="${CSS.escape(e.value)}"]`,penalty:.5})))}function u(t){return Array.from(t.classList).filter(e.className).map((e=>({name:"."+CSS.escape(e),penalty:1})))}function f(t){const n=t.tagName.toLowerCase();return e.tagName(n)?{name:n,penalty:2}:null}function d(e){const t=e.parentNode;if(!t)return null;let n=t.firstChild;if(!n)return null;let r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}function m(e,t){return{name:e.name+`:nth-child(${t})`,penalty:e.penalty+1}}function h(e){return"html"!==e.name&&!e.name.startsWith("#")}function p(...e){const t=e.filter(g);return t.length>0?t:null}function g(e){return null!=e}function*y(e,t=[]){if(e.length>0)for(let n of e[0])yield*y(e.slice(1,e.length),t.concat(n));else yield t}function w(e){return[...e].sort(((e,t)=>l(e)-l(t)))}function*b(t,n,r={counter:0,visited:new Map}){if(t.length>2&&t.length>e.optimizedMinLength)for(let o=1;oe.maxNumberOfTries)return;r.counter+=1;const l=[...t];l.splice(o,1);const s=i(l);if(r.visited.has(s))return;a(l)&&v(l,n)&&(yield l,r.visited.set(s,!0),yield*b(l,n,r))}}function v(e,n){return t.querySelector(i(e))===n}function N(e,t){let n="",r=null,o=!1;try{if(r=e.nodeName&&"string"==typeof e.nodeName?e.nodeName.toLowerCase():null,!r)return null;n=`${r}`,e.getAttribute("id")&&(n=`${n}#${CSS.escape(e.getAttribute("id"))}`,o=!0);const t=["data-test-id","data-testid","data-test","data-cy"];if(e.matches(t.map((e=>`[${e}]`)).join(",")))for(const r of t){const t=e.getAttribute(r);if(t){n=`${n}[${r}="${CSS.escape(t)}"]`;break}}if(["input","button","textarea","select","option"].includes(r)){e.getAttribute("type")&&(n=`${n}[type="${CSS.escape(e.getAttribute("type"))}"]`),e.getAttribute("name")&&(n=`${n}[name="${CSS.escape(e.getAttribute("name"))}"]`);const t=e.closest("form");if(t){let e="form";t.getAttribute("id")&&(e=`${e}#${CSS.escape(t.getAttribute("id"))}`),n=`${e} ${n}`}}const i=e.getAttribute("aria-label");if(i&&!o&&(n=`${n}[aria-label="${CSS.escape(i)}"]`),n){const t=e.closest("body");if(t)try{1!==t.querySelectorAll(n).length&&(n="")}catch(e){n=""}}}catch(e){}return n}function E(e,t){let n,r=e,o=[];for(;r;){let e=0,n=r.previousElementSibling;for(;n;)n.nodeName===r.nodeName&&e++,n=n.previousElementSibling;let i=r.nodeName.toLowerCase();e>0&&(i=i+"["+(e+1)+"]"),r!==t&&o.unshift(i),r=r.parentNode}if(n="/"+o.join("/"),function(e,t){const n=t.evaluate(e,t,null,XPathResult.ANY_TYPE,null),r=n.iterateNext();return r}(n,t)===e)return n}const S={},C={keydown:null,return:null,blur:null,change:null,click:null,dblclick:null,contextmenu:null,focus:null,mouseover:null,mouseout:null};let $=!1;function A(e,t){let n;var r;let o,i;function l(e,t,r){let i=null;const l=[];let s=e,c=0;for(;s&&s!==o.root.parentElement;){let e=w(f(s))||w(...d(s))||w(...m(s))||w(h(s))||[{name:"*",penalty:3}];const u=p(s);if(t===n.All)u&&(e=e.concat(e.filter(y).map((e=>g(e,u)))));else if(t===n.Two)e=e.slice(0,1),u&&(e=e.concat(e.filter(y).map((e=>g(e,u)))));else if(t===n.One){const[t]=e=e.slice(0,1);u&&y(t)&&(e=[g(t,u)])}for(const t of e)t.level=c;if(l.push(e),l.length>=o.seedMinLength&&(i=a(l,r),i))break;s=s.parentElement,c++}return i||(i=a(l,r)),i}function a(e,t){const n=N(v(e));if(n.length>o.threshold)return t?t():null;for(const e of n)if(u(e))return e;return null}function s(e){let t=e[0],n=t.name;for(let r=1;r ${n}`:`${e[r].name} ${n}`,t=e[r]}return n}function c(e){return e.map((e=>e.penalty)).reduce(((e,t)=>e+t),0)}function u(e){switch(i.querySelectorAll(s(e)).length){case 0:throw new Error(`Can't select any node with this selector: ${s(e)}`);case 1:return!0;default:return!1}}function f(e){const t=e.getAttribute("id");return t&&o.idName(t)?{name:`#${L(t,{isIdentifier:!0})}`,penalty:0}:null}function d(e){return Array.from(e.attributes).filter((e=>o.attr(e.name,e.value))).map((e=>({name:"["+L(e.name,{isIdentifier:!0})+'="'+L(e.value)+'"]',penalty:.5})))}function m(e){return Array.from(e.classList).filter(o.className).map((e=>({name:"."+L(e,{isIdentifier:!0}),penalty:1})))}function h(e){const t=e.tagName.toLowerCase();return o.tagName(t)?{name:t,penalty:2}:null}function p(e){const t=e.parentNode;if(!t)return null;let n=t.firstChild;if(!n)return null;let r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}function g(e,t){return{name:e.name+`:nth-child(${t})`,penalty:e.penalty+1}}function y(e){return"html"!==e.name&&!e.name.startsWith("#")}function w(...e){const t=e.filter(b);return 0c(e)-c(t)))}function E(e,t){return i.querySelector(s(e))===t}(r=n||(n={}))[r.All=0]="All",r[r.Two=1]="Two",r[r.One=2]="One";const S=/[ -,\.\/:-@\[-\^`\{-~]/,C=/[ -,\.\/:-@\[\]\^`\{-~]/,$=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,A={escapeEverything:!1,isIdentifier:!1,quotes:"single",wrap:!1};function L(e,t={}){const n=Object.assign(Object.assign({},A),t);"single"!==n.quotes&&"double"!==n.quotes&&(n.quotes="single");const r="double"==n.quotes?'"':"'",o=n.isIdentifier,i=e.charAt(0);let l="",a=0;for(const t=e.length;ac||126=c&&a!0,className:()=>!0,tagName:()=>!0,attr:()=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4};o=Object.assign(Object.assign({},T),t),i=function(e,t){return e.nodeType===Node.DOCUMENT_NODE?e:e===t.root?e.ownerDocument:e}(o.root,T);let x=l(e,n.All,(()=>l(e,n.Two,(()=>l(e,n.One)))));if(x){const t=N(function*e(t,n,r={counter:0,visited:new Map}){if(2o.optimizedMinLength)for(let i=1;io.maxNumberOfTries)return;r.counter+=1;const l=[...t];l.splice(i,1);const a=s(l);if(r.visited.has(a))return;u(l)&&E(l,n)&&(yield l,r.visited.set(a,!0),yield*e(l,n,r))}}(x,e));return 0{if(!i.isRecording)return;let l=!1,a=null;function s(e){e&&"mouseover"===e.type&&!l||function(e,t,r,o){let i=!1,l=null,a=null;e&&e.composed&&e.composedPath&&(a=e.composedPath());let s=-1;a&&a.length>0&&(s=a.findIndex((e=>e instanceof ShadowRoot))),l=s>-1?a[0]:e.target;const c=e.type;let u=null,f=null;if(!l||!l.getAttribute)return;u=l.nodeName.toLowerCase(),f=l.getAttribute("type");let d=null,m=null;try{m=function(e){let t=null;try{if(t=e.nodeName&&"string"==typeof e.nodeName?e.nodeName.toLowerCase():null,!t)return e;if(["input","button","a","textarea","select","option","progress"].includes(t))return e;const n=e.closest("button,a");if(n)return n;const r=e.closest("svg");r&&(e=r);const o=["data-test-id","data-testid","data-test","data-cy"];if(e.matches(o.map((e=>`[${e}]`)).join(",")))return e;if(e.parentNode.matches(o.map((e=>`[${e}]`)).join(",")))return e.parentNode}catch(e){}return e}(l),d=N(m)}catch(e){}if(!d)try{d=n(m,{root:t,idName:e=>!/^[0-9]+.*/i.test(e),className:e=>!e.includes("focus")&&!e.includes("highlight")&&!/^[0-9]+.*/i.test(e)})}catch(e){}if(d&&"html"===d.toLowerCase())return;let h=null;try{h=E(m,t)}catch(e){}s>-1&&(h="/html/node/shadow");let p={timestamp:(new Date).getTime(),css:d||l,xpath:h||""},g={};if("click"===c){if(C.click=l,!(C.return!==C.change||l===C.return||"input"!==u&&"button"!==u||"submit"!==f&&"image"!==f||null===C.return))return;if("input"===u&&("checkbox"===f||"radio"===f))return;if("label"===u){const e=l.getAttribute("for");if(e&&document.getElementById(e))return}let o="click";if("canvas"===u){const t=l.getBoundingClientRect(),n={x:e.clientX-t.left,y:e.clientY-t.top,width:t.width,height:t.height};p={...p,coords:n},o="bclick"}if(g={...p,type:o,value:(l.value||l.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r},"bclick"===o&&s>-1&&a){const e=a[s].host;if(e){let r=null;try{r=N(e)}catch(e){}if(!r)try{r=n(e,{root:t,idName:e=>!/^[0-9]+.*/i.test(e),className:e=>!e.includes("focus")&&!e.includes("highlight")&&!/^[0-9]+.*/i.test(e)})}catch(e){}r&&(g.shadow_host_css=r)}}}else if("dblclick"===c)C.dblclick=l,g={...p,type:"dblclick",value:(l.value||l.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r};else if("contextmenu"===c)C.contextmenu=l,g={...p,type:"contextmenu",value:(l.value||l.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r};else if("focus"===c);else if("mouseover"===c)$&&(clearTimeout($),$=!1),$=setTimeout((()=>{$=!1,C.mouseover=l,g={...p,type:"mouseover",value:(l.value||l.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:r},g&&g.type&&o&&o({messageType:"events",event:{...g}})}),500);else if("mouseout"===c);else if("keydown"===c)C.keydown=l,["input","textarea"].indexOf(u)>-1&&(S[l]=l.value),"input"===u&&13===e.keyCode&&(i=!0,C.return=l,g={...p,type:"fill_value",value:l.value,frame:r});else if("blur"===c){if(C.blur=l,["input","textarea"].indexOf(u)>-1){if(S[l]=l.value,l===C.return)return void(C.return=null);if("input"===u&&("submit"===l.type||"button"===l.type||"image"===l.type))return;g={...p,type:"fill_value",value:l.value,frame:r}}}else if("change"===c)if(C.change=l,"input"===u)"checkbox"!==f&&"radio"!==f||(g={...p,type:"change",subtype:"check",checked:l.checked,frame:r});else if("select"===u)if(l.multiple){const e=[];for(let t=0;t{window!==window.top?window.parent.postMessage({source:"event-from-iframe",obj:{...e},framePath:[]},"*"):chrome.runtime.sendMessage(e)}))}window===window.top&&window.addEventListener("message",(e=>{if(e.data&&e.data.source&&"event-from-iframe"===e.data.source){const t=document.querySelectorAll("iframe, frame");let n=!1;for(const r of t)if(r.contentWindow===e.source){n=!0;break}if(!n)return;const r={...e.data.obj},o=e.data.framePath||[];for(const n of t)if(n.contentWindow===e.source){let e=null;try{e=N(n)}catch(e){}if(!e)try{e=A(n,{root:window.document,idName:e=>!/^[0-9]+.*/i.test(e),className:e=>!e.includes("focus")&&!e.includes("highlight")&&!/^[0-9]+.*/i.test(e)})}catch(e){}if(e&&r.event){const t=[e,...o];r.event.frame=t.join(" >>> "),chrome.runtime.sendMessage(r)}break}}})),window!==window.top&&window.addEventListener("message",(e=>{if(e.data&&e.data.source&&"event-from-iframe"===e.data.source){const t=document.querySelectorAll("iframe, frame");let n=!1;for(const r of t)if(r.contentWindow===e.source){n=!0;break}if(!n)return;const r=e.data.framePath||[];for(const n of t)if(n.contentWindow===e.source){let t=null;try{t=N(n)}catch(e){}if(!t)try{t=A(n,{root:window.document,idName:e=>!/^[0-9]+.*/i.test(e),className:e=>!e.includes("focus")&&!e.includes("highlight")&&!/^[0-9]+.*/i.test(e)})}catch(e){}t&&r.push(t),window.parent.postMessage({source:"event-from-iframe",obj:e.data.obj,framePath:r},"*");break}}})),i.isRecording&&(t=!0,e=document.title,function(){if(!t)return document.title=`${e}`,o=!1,void(r&&(clearInterval(r),r=!1));r=setInterval((()=>{o?(document.title=`${e}`,o=!1):(document.title=`🔴 ${e}`,o=!0)}),1e3)}(),window===window.top&&chrome.runtime.sendMessage({messageType:"events",event:{type:"goto",timestamp:(new Date).getTime(),windowWidth:window.innerWidth,windowHeight:window.innerHeight,url:window.location.href}}),document.addEventListener("click",s,!0),document.addEventListener("mouseover",s,!0),document.addEventListener("dblclick",s,!0),document.addEventListener("contextmenu",s,!0),document.addEventListener("keydown",s,!0),document.addEventListener("blur",s,!0),document.addEventListener("change",s,!0));const c={attributes:!1,childList:!0,subtree:!0},u=new MutationObserver((async(e,t)=>{l=!0,a&&(clearTimeout(a),a=null),a=setTimeout((()=>{l=!1}),200)}));document.body&&u.observe(document.body,c)}))}()})(); \ No newline at end of file diff --git a/test-build/manifest.json b/test-build/manifest.json index 9928474..9767b2b 100644 --- a/test-build/manifest.json +++ b/test-build/manifest.json @@ -1 +1 @@ -{"version":"1.0.0","manifest_version":3,"name":"Snyk API & Web Sequence Recorder","action":{"default_popup":"popup.html","default_icon":{"16":"icon-34.png","48":"icon-48.png"}},"icons":{"128":"icon-128.png"},"background":{"service_worker":"background.bundle.js"},"content_scripts":[{"matches":["http://*/*","https://*/*"],"js":["contentScript.bundle.js"],"css":["content.styles.css"],"run_at":"document_start","all_frames":true,"match_about_blank":true}],"web_accessible_resources":[{"resources":["content.styles.css","icon-128.png","icon-34.png"],"matches":[""]}],"permissions":["storage","activeTab"],"host_permissions":["http://*/*","https://*/*"]} \ No newline at end of file +{"version":"1.1.0","manifest_version":3,"name":"Snyk API & Web Sequence Recorder","action":{"default_popup":"popup.html","default_icon":{"16":"icon-34.png","48":"icon-48.png"}},"icons":{"128":"icon-128.png"},"background":{"service_worker":"background.bundle.js"},"content_scripts":[{"matches":["http://*/*","https://*/*"],"js":["contentScript.bundle.js"],"css":["content.styles.css"],"run_at":"document_start","all_frames":true,"match_about_blank":true}],"web_accessible_resources":[{"resources":["content.styles.css","icon-128.png","icon-34.png"],"matches":[""]}],"permissions":["storage","activeTab"],"host_permissions":["http://*/*","https://*/*"]} \ No newline at end of file diff --git a/test-build/reviewpage.bundle.js b/test-build/reviewpage.bundle.js index 2bf2dbb..59fff4f 100644 --- a/test-build/reviewpage.bundle.js +++ b/test-build/reviewpage.bundle.js @@ -27,4 +27,4 @@ var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),l=Symbol.for("rea * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -function n(e,t){var n=e.length;e.push(t);e:for(;0>>1,l=e[r];if(!(0>>1;ra(i,n))sa(c,i)?(e[r]=c,e[s]=n,r=s):(e[r]=i,e[u]=n,r=u);else{if(!(sa(c,n)))break e;e[r]=c,e[s]=n,r=s}}}return t}function a(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;t.unstable_now=function(){return o.now()}}else{var u=Date,i=u.now();t.unstable_now=function(){return u.now()-i}}var s=[],c=[],f=1,d=null,p=3,m=!1,h=!1,g=!1,v="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,b="undefined"!=typeof setImmediate?setImmediate:null;function k(e){for(var t=r(c);null!==t;){if(null===t.callback)l(c);else{if(!(t.startTime<=e))break;l(c),t.sortIndex=t.expirationTime,n(s,t)}t=r(c)}}function w(e){if(g=!1,k(e),!h)if(null!==r(s))h=!0,O(S);else{var t=r(c);null!==t&&R(w,t.startTime-e)}}function S(e,n){h=!1,g&&(g=!1,y(C),C=-1),m=!0;var a=p;try{for(k(n),d=r(s);null!==d&&(!(d.expirationTime>n)||e&&!z());){var o=d.callback;if("function"==typeof o){d.callback=null,p=d.priorityLevel;var u=o(d.expirationTime<=n);n=t.unstable_now(),"function"==typeof u?d.callback=u:d===r(s)&&l(s),k(n)}else l(s);d=r(s)}if(null!==d)var i=!0;else{var f=r(c);null!==f&&R(w,f.startTime-n),i=!1}return i}finally{d=null,p=a,m=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var x,E=!1,_=null,C=-1,N=5,P=-1;function z(){return!(t.unstable_now()-Pe||125o?(e.sortIndex=a,n(c,e),null===r(s)&&e===r(c)&&(g?(y(C),C=-1):g=!0,R(w,a-o))):(e.sortIndex=u,n(s,e),h||m||(h=!0,O(S))),e},t.unstable_shouldYield=z,t.unstable_wrapCallback=function(e){var t=p;return function(){var n=p;p=t;try{return e.apply(this,arguments)}finally{p=n}}}},982:(e,t,n)=>{e.exports=n(463)},72:e=>{var t=[];function n(e){for(var n=-1,r=0;r{var t={};e.exports=function(e,n){var r=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},159:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56:(e,t,n)=>{e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},825:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var l=void 0!==n.layer;l&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,l&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var a=n.sourceMap;a&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function n(r){var l=t[r];if(void 0!==l)return l.exports;var a=t[r]={id:r,exports:{}};return e[r](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.p="/",n.nc=void 0;var r=n(540),l=n(961);const a=n.p+"adc8b34de96d4007231c.svg";let o=!1;const u=e=>{const[t,n]=(0,r.useState)([]),[l,u]=(0,r.useState)([]),[i,s]=(0,r.useState)([]),[c,f]=(0,r.useState)({status:!1,error:!1,msg:"Successfully copied to clipboard"}),[d,p]=(0,r.useState)(!0);function m(e){const t=JSON.parse(JSON.stringify(e)),n=[];t.forEach((e=>{e.opt.checked&&("goto"===e.type&&(e.urlType=e.opt.urlType),delete e.opt,n.push(e))})),s(n)}function h(e,t,n){if(-1===["css","fill_value"].indexOf(n))return;const r=JSON.parse(JSON.stringify(l));"css"===n?(r[t].opt.cssEditMode=!0,r[t].opt.cssOldValue=r[t].css):"fill_value"===n&&(r[t].opt.fillValueEditMode=!0,r[t].opt.fillValueOldValue=r[t].value),u(r),m(r)}function g(e,t,n){if(-1===["css","fill_value"].indexOf(n))return;const r=e.target,a=JSON.parse(JSON.stringify(l));"css"===n?a[t].css=r.value:"fill_value"===n&&(a[t].value=r.value),u(a),m(a)}function v(e,t,n){if(-1===["css","fill_value"].indexOf(n))return;const r=JSON.parse(JSON.stringify(l));"css"===n?(r[t].css=r[t].opt.cssOldValue,r[t].opt.cssEditMode=!1):"fill_value"===n&&(r[t].value=r[t].opt.fillValueOldValue,r[t].opt.fillValueEditMode=!1),u(r),m(r)}function y(e,t,n){if(e.preventDefault(),-1===["css","fill_value"].indexOf(n))return;const r=JSON.parse(JSON.stringify(l));"css"===n?r[t].opt.cssEditMode=!1:"fill_value"===n&&(r[t].opt.fillValueEditMode=!1),u(r),m(r)}return(0,r.useEffect)((()=>{chrome.runtime.onMessage.addListener(((e,t,r)=>{if("recording_data"===e.messageType&&!o){o=!0,n(e.recordingData||[]);const t=[].concat(e.recordingData).map(((e,t)=>(e.opt={},e.opt.checked=!0,"goto"===e.type&&(0===t?(e.opt.urlType="force",e.opt.urlDisabled=!0):(e.opt.urlType="ignore",e.opt.urlDisabled=!1)),e)));u(t),m(t)}})),chrome.runtime.sendMessage({messageType:"give_recording_data"})}),[]),r.createElement("div",{className:"App"},r.createElement("header",{className:"instructions"},r.createElement("div",{className:"header"},r.createElement("img",{src:a,alt:"Snyk API & Web"}),r.createElement("h1",null,"Sequence Recorder"))),r.createElement("div",{className:"main"},l&&l.length?r.createElement(r.Fragment,null,r.createElement("p",null,"You can copy or download the recorded information here or through the plugin window."),r.createElement("div",{className:"buttons-container"},r.createElement("button",{type:"button",className:"App-button",onClick:()=>{!function(){const e=document.getElementById("input-copy-to-clipboard");if(e){e.select();const t=e.value;let n=!1;try{n=document.execCommand("copy")}catch(e){try{window.clipboardData.setData("text",t),n=!0}catch(e){}}n?(f({status:!0,error:!1,msg:"Successfully copied to clipboard"}),setTimeout((()=>{f({status:!1,error:!1,msg:""})}),3e3)):(f({status:!0,error:!0,msg:"Error on copy to clipboard"}),setTimeout((()=>{f({status:!1,error:!1,msg:""})}),5e3))}}()}},"Copy to clipboard"),r.createElement("button",{type:"button",className:"App-button",onClick:()=>{!function(){let e=null;if(e=new Blob([JSON.stringify(i,null,2)],{type:"text/plain;charset=utf-8"}),!e)return;const t=document.createElement("a");t.download="snyk-api-and-web-recording.json",t.rel="noopener",t.href=URL.createObjectURL(e);try{t.dispatchEvent(new MouseEvent("click"))}catch(e){const n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(n)}}()}},"Download")),r.createElement("div",{className:"advance_check_container"},r.createElement("input",{type:"checkbox",id:"review_advanced_options",value:"1",className:"form-control input_custom",checked:d,onChange:e=>{!function(e){e.target.checked?p(!0):p(!1)}(e)}}),r.createElement("label",{htmlFor:"review_advanced_options",className:"review_advanced_options_text"},"Advanced options")),r.createElement("p",null,"After saving your sequence, make sure to import it to your target settings at Snyk API & Web, so it is followed during scans.")):r.createElement("h3",null,r.createElement("strong",null,"No data has been recorded")),r.createElement("div",{className:"copy-status-container"},c.status?r.createElement("div",{className:c.error?"copy-status error":"copy-status success"},c.msg):null),l&&l.length&&d?r.createElement(r.Fragment,null,r.createElement("div",{className:"advanced_instructions"},r.createElement("p",{className:"center"},"You can review the steps recorded below."," ","Note that changing the sequence in any way could prevent the crawler from successfully replaying it."),r.createElement("p",null,"Some tips:"),r.createElement("ul",null,r.createElement("li",null,"You can edit the CSS selectors (click on the CSS selector) to adjust some possible variable selectors."," ",'For instance for the selector "',r.createElement("code",null,r.createElement("b",null,"#foo > .nav-item.item_42")),'" where "42" is an ID,'," ",'using "',r.createElement("code",null,r.createElement("b",null,".item_42")),'" is not recomended.'),r.createElement("li",null,'You can edit "',r.createElement("b",null,"fill with value"),'" values (click on the text value) to use random values. For instance, in a registration form where the email needs to be unique,'," ","you can use the value ",r.createElement("code",null,"email+",r.createElement("b",null,"{RAND_STRING}"),"@example.com"),".",r.createElement("br",null),"Possible values:",r.createElement("ul",null,r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_STRING}"))," - random string"),r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_STRING[5]}"))," - random string with length X (e.g. 5)"),r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_NUMBER}"))," - random number"),r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_NUMBER[10-99]}"))," - random number between X and Y (e.g. 10 and 99)"))))),r.createElement("table",{className:"review_table"},r.createElement("thead",null,r.createElement("tr",null,r.createElement("th",{className:"table_id"}),r.createElement("th",{className:"table_type"}),r.createElement("th",{className:"table_selector"}),r.createElement("th",{className:"table_value"}))),r.createElement("tbody",null,l.map(((e,t)=>r.createElement("tr",{className:"table_tr "+(t%2==0?"odd":"even"),key:`item_${t}`},r.createElement("td",null,r.createElement("input",{type:"checkbox",name:`item_name_${t}`,value:t,disabled:0===t,checked:e.opt.checked,className:"t_line_checkbox",onChange:e=>{!function(e,t){const n=e.target,r=JSON.parse(JSON.stringify(l));r[t].opt.checked=!!n.checked,u(r),m(r)}(e,t)}})),r.createElement("td",null,r.createElement("span",{className:"t_item_type "},function(e){let t=e;switch(e){case"fill_value":t="fill with value";break;case"press_key":t="press [ENTER]";break;case"goto":t="go to";break;default:t=e}return t}(e.type))),r.createElement("td",null,"goto"===e.type?r.createElement("span",{className:"t_url"},e.url):e.opt.cssEditMode?r.createElement("form",{method:"post",action:"",onSubmit:e=>{y(e,t,"css")}},r.createElement("input",{type:"text",className:"t_selector_input",value:e.css,onChange:e=>{g(e,t,"css")}}),r.createElement("button",{type:"submit",className:"t_btn_ok"},"Save"),r.createElement("button",{type:"button",className:"t_btn_cancel",onClick:e=>{v(0,t,"css")}},"Cancel")):r.createElement("span",{className:"t_selector",onClick:e=>{h(0,t,"css")}},e.css)),r.createElement("td",null,"fill_value"===e.type?e.opt.fillValueEditMode?r.createElement("form",{method:"post",action:"",onSubmit:e=>{y(e,t,"fill_value")}},r.createElement("input",{type:"text",className:"t_fill_value_input",value:e.value,onChange:e=>{g(e,t,"fill_value")}}),r.createElement("button",{type:"submit",className:"t_btn_ok"},"Save"),r.createElement("button",{type:"button",className:"t_btn_cancel",onClick:e=>{v(0,t,"fill_value")}},"Cancel")):r.createElement("span",{className:"t_selector",onClick:e=>{h(0,t,"fill_value")}},e.value):null,"change"===e.type&&"check"===e.subtype?e.checked?"checked":"not checked":null,"change"===e.type&&"select"===e.subtype?`index ${e.selected}`:null,"goto"===e.type?r.createElement("span",null,"Navigate to URL"):null))))))):null),r.createElement("div",null),l.length?r.createElement("textarea",{id:"input-copy-to-clipboard",readOnly:!0,value:JSON.stringify(i,null,2)}):null)};var i=n(72),s=n.n(i),c=n(825),f=n.n(c),d=n(659),p=n.n(d),m=n(56),h=n.n(m),g=n(159),v=n.n(g),y=n(113),b=n.n(y),k=n(639),w={};w.styleTagTransform=b(),w.setAttributes=h(),w.insert=p().bind(null,"head"),w.domAPI=f(),w.insertStyleElement=v();s()(k.A,w);k.A&&k.A.locals&&k.A.locals;(0,l.render)(r.createElement(u,null),window.document.querySelector("#app-container"))})(); \ No newline at end of file +function n(e,t){var n=e.length;e.push(t);e:for(;0>>1,l=e[r];if(!(0>>1;ra(i,n))sa(c,i)?(e[r]=c,e[s]=n,r=s):(e[r]=i,e[u]=n,r=u);else{if(!(sa(c,n)))break e;e[r]=c,e[s]=n,r=s}}}return t}function a(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;t.unstable_now=function(){return o.now()}}else{var u=Date,i=u.now();t.unstable_now=function(){return u.now()-i}}var s=[],c=[],f=1,d=null,p=3,m=!1,h=!1,g=!1,v="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,b="undefined"!=typeof setImmediate?setImmediate:null;function k(e){for(var t=r(c);null!==t;){if(null===t.callback)l(c);else{if(!(t.startTime<=e))break;l(c),t.sortIndex=t.expirationTime,n(s,t)}t=r(c)}}function w(e){if(g=!1,k(e),!h)if(null!==r(s))h=!0,O(S);else{var t=r(c);null!==t&&R(w,t.startTime-e)}}function S(e,n){h=!1,g&&(g=!1,y(C),C=-1),m=!0;var a=p;try{for(k(n),d=r(s);null!==d&&(!(d.expirationTime>n)||e&&!z());){var o=d.callback;if("function"==typeof o){d.callback=null,p=d.priorityLevel;var u=o(d.expirationTime<=n);n=t.unstable_now(),"function"==typeof u?d.callback=u:d===r(s)&&l(s),k(n)}else l(s);d=r(s)}if(null!==d)var i=!0;else{var f=r(c);null!==f&&R(w,f.startTime-n),i=!1}return i}finally{d=null,p=a,m=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var x,E=!1,_=null,C=-1,N=5,P=-1;function z(){return!(t.unstable_now()-Pe||125o?(e.sortIndex=a,n(c,e),null===r(s)&&e===r(c)&&(g?(y(C),C=-1):g=!0,R(w,a-o))):(e.sortIndex=u,n(s,e),h||m||(h=!0,O(S))),e},t.unstable_shouldYield=z,t.unstable_wrapCallback=function(e){var t=p;return function(){var n=p;p=t;try{return e.apply(this,arguments)}finally{p=n}}}},982:(e,t,n)=>{e.exports=n(463)},72:e=>{var t=[];function n(e){for(var n=-1,r=0;r{var t={};e.exports=function(e,n){var r=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},159:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56:(e,t,n)=>{e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},825:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var l=void 0!==n.layer;l&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,l&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var a=n.sourceMap;a&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function n(r){var l=t[r];if(void 0!==l)return l.exports;var a=t[r]={id:r,exports:{}};return e[r](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.p="/",n.nc=void 0;var r=n(540),l=n(961);const a=n.p+"adc8b34de96d4007231c.svg";let o=!1;const u=e=>{const[t,n]=(0,r.useState)([]),[l,u]=(0,r.useState)([]),[i,s]=(0,r.useState)([]),[c,f]=(0,r.useState)({status:!1,error:!1,msg:"Successfully copied to clipboard"}),[d,p]=(0,r.useState)(!0);function m(e){const t=JSON.parse(JSON.stringify(e)),n=[];t.forEach((e=>{e.opt.checked&&("goto"===e.type&&(e.urlType=e.opt.urlType),delete e.opt,n.push(e))})),s(n)}function h(e,t,n){if(-1===["css","fill_value"].indexOf(n))return;const r=JSON.parse(JSON.stringify(l));"css"===n?(r[t].opt.cssEditMode=!0,r[t].opt.cssOldValue=r[t].css):"fill_value"===n&&(r[t].opt.fillValueEditMode=!0,r[t].opt.fillValueOldValue=r[t].value),u(r),m(r)}function g(e,t,n){if(-1===["css","fill_value"].indexOf(n))return;const r=e.target,a=JSON.parse(JSON.stringify(l));"css"===n?a[t].css=r.value:"fill_value"===n&&(a[t].value=r.value),u(a),m(a)}function v(e,t,n){if(-1===["css","fill_value"].indexOf(n))return;const r=JSON.parse(JSON.stringify(l));"css"===n?(r[t].css=r[t].opt.cssOldValue,r[t].opt.cssEditMode=!1):"fill_value"===n&&(r[t].value=r[t].opt.fillValueOldValue,r[t].opt.fillValueEditMode=!1),u(r),m(r)}function y(e,t,n){if(e.preventDefault(),-1===["css","fill_value"].indexOf(n))return;const r=JSON.parse(JSON.stringify(l));"css"===n?r[t].opt.cssEditMode=!1:"fill_value"===n&&(r[t].opt.fillValueEditMode=!1),u(r),m(r)}return(0,r.useEffect)((()=>{chrome.runtime.onMessage.addListener(((e,t,r)=>{if("recording_data"===e.messageType&&!o){o=!0,n(e.recordingData||[]);const t=[].concat(e.recordingData).map(((e,t)=>(e.opt={},e.opt.checked=!0,"goto"===e.type&&(0===t?(e.opt.urlType="force",e.opt.urlDisabled=!0):(e.opt.urlType="ignore",e.opt.urlDisabled=!1)),e)));u(t),m(t)}})),chrome.runtime.sendMessage({messageType:"give_recording_data"})}),[]),r.createElement("div",{className:"App"},r.createElement("header",{className:"instructions"},r.createElement("div",{className:"header"},r.createElement("img",{src:a,alt:"Snyk API & Web"}),r.createElement("h1",null,"Sequence Recorder"))),r.createElement("div",{className:"main"},l&&l.length?r.createElement(r.Fragment,null,r.createElement("p",null,"You can copy or download the recorded information here or through the plugin window."),r.createElement("div",{className:"buttons-container"},r.createElement("button",{type:"button",className:"App-button",onClick:()=>{!function(){const e=document.getElementById("input-copy-to-clipboard");if(e){e.select();const t=e.value;let n=!1;try{n=document.execCommand("copy")}catch(e){try{window.clipboardData.setData("text",t),n=!0}catch(e){}}n?(f({status:!0,error:!1,msg:"Successfully copied to clipboard"}),setTimeout((()=>{f({status:!1,error:!1,msg:""})}),3e3)):(f({status:!0,error:!0,msg:"Error on copy to clipboard"}),setTimeout((()=>{f({status:!1,error:!1,msg:""})}),5e3))}}()}},"Copy to clipboard"),r.createElement("button",{type:"button",className:"App-button",onClick:()=>{!function(){let e=null;if(e=new Blob([JSON.stringify(i,null,2)],{type:"text/plain;charset=utf-8"}),!e)return;const t=document.createElement("a");t.download="snyk-api-and-web-recording.json",t.rel="noopener",t.href=URL.createObjectURL(e);try{t.dispatchEvent(new MouseEvent("click"))}catch(e){const n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(n)}}()}},"Download")),r.createElement("div",{className:"advance_check_container"},r.createElement("input",{type:"checkbox",id:"review_advanced_options",value:"1",className:"form-control input_custom",checked:d,onChange:e=>{!function(e){e.target.checked?p(!0):p(!1)}(e)}}),r.createElement("label",{htmlFor:"review_advanced_options",className:"review_advanced_options_text"},"Advanced options")),r.createElement("p",null,"After saving your sequence, make sure to import it to your target settings at Snyk API & Web, so it is followed during scans.")):r.createElement("h3",null,r.createElement("strong",null,"No data has been recorded")),r.createElement("div",{className:"copy-status-container"},c.status?r.createElement("div",{className:c.error?"copy-status error":"copy-status success"},c.msg):null),l&&l.length&&d?r.createElement(r.Fragment,null,r.createElement("div",{className:"advanced_instructions"},r.createElement("p",{className:"center"},"You can review the steps recorded below."," ","Note that changing the sequence in any way could prevent the crawler from successfully replaying it."),r.createElement("p",null,"Some tips:"),r.createElement("ul",null,r.createElement("li",null,"You can edit the CSS selectors (click on the CSS selector) to adjust some possible variable selectors."," ",'For instance for the selector "',r.createElement("code",null,r.createElement("b",null,"#foo > .nav-item.item_42")),'" where "42" is an ID,'," ",'using "',r.createElement("code",null,r.createElement("b",null,".item_42")),'" is not recomended.'),r.createElement("li",null,'You can edit "',r.createElement("b",null,"fill with value"),'" values (click on the text value) to use random values. For instance, in a registration form where the email needs to be unique,'," ","you can use the value ",r.createElement("code",null,"email+",r.createElement("b",null,"{RAND_STRING}"),"@example.com"),".",r.createElement("br",null),"Possible values:",r.createElement("ul",null,r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_STRING}"))," - random string"),r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_STRING[5]}"))," - random string with length X (e.g. 5)"),r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_NUMBER}"))," - random number"),r.createElement("li",null,r.createElement("code",null,r.createElement("b",null,"{RAND_NUMBER[10-99]}"))," - random number between X and Y (e.g. 10 and 99)"))))),r.createElement("table",{className:"review_table"},r.createElement("thead",null,r.createElement("tr",null,r.createElement("th",{className:"table_id"}),r.createElement("th",{className:"table_type"}),r.createElement("th",{className:"table_selector"}),r.createElement("th",{className:"table_value"}))),r.createElement("tbody",null,l.map(((e,t)=>r.createElement("tr",{className:"table_tr "+(t%2==0?"odd":"even"),key:`item_${t}`},r.createElement("td",null,r.createElement("input",{type:"checkbox",name:`item_name_${t}`,value:t,disabled:0===t,checked:e.opt.checked,className:"t_line_checkbox",onChange:e=>{!function(e,t){const n=e.target,r=JSON.parse(JSON.stringify(l));r[t].opt.checked=!!n.checked,u(r),m(r)}(e,t)}})),r.createElement("td",null,r.createElement("span",{className:"t_item_type "},function(e){let t=e;switch(e){case"fill_value":t="fill with value";break;case"press_key":t="press [ENTER]";break;case"goto":t="go to";break;case"click":case"bclick":t="click";break;default:t=e}return t}(e.type))),r.createElement("td",null,"goto"===e.type?r.createElement("span",{className:"t_url"},e.url):e.opt.cssEditMode?r.createElement("form",{method:"post",action:"",onSubmit:e=>{y(e,t,"css")}},r.createElement("input",{type:"text",className:"t_selector_input",value:e.css,onChange:e=>{g(e,t,"css")}}),r.createElement("button",{type:"submit",className:"t_btn_ok"},"Save"),r.createElement("button",{type:"button",className:"t_btn_cancel",onClick:e=>{v(0,t,"css")}},"Cancel")):r.createElement("span",{className:"t_selector",onClick:e=>{h(0,t,"css")}},e.css)),r.createElement("td",null,"fill_value"===e.type?e.opt.fillValueEditMode?r.createElement("form",{method:"post",action:"",onSubmit:e=>{y(e,t,"fill_value")}},r.createElement("input",{type:"text",className:"t_fill_value_input",value:e.value,onChange:e=>{g(e,t,"fill_value")}}),r.createElement("button",{type:"submit",className:"t_btn_ok"},"Save"),r.createElement("button",{type:"button",className:"t_btn_cancel",onClick:e=>{v(0,t,"fill_value")}},"Cancel")):r.createElement("span",{className:"t_selector",onClick:e=>{h(0,t,"fill_value")}},e.value):null,"change"===e.type&&"check"===e.subtype?e.checked?"checked":"not checked":null,"change"===e.type&&"select"===e.subtype?`index ${e.selected}`:null,"goto"===e.type?r.createElement("span",null,"Navigate to URL"):null))))))):null),r.createElement("div",null),l.length?r.createElement("textarea",{id:"input-copy-to-clipboard",readOnly:!0,value:JSON.stringify(i,null,2)}):null)};var i=n(72),s=n.n(i),c=n(825),f=n.n(c),d=n(659),p=n.n(d),m=n(56),h=n.n(m),g=n(159),v=n.n(g),y=n(113),b=n.n(y),k=n(639),w={};w.styleTagTransform=b(),w.setAttributes=h(),w.insert=p().bind(null,"head"),w.domAPI=f(),w.insertStyleElement=v();s()(k.A,w);k.A&&k.A.locals&&k.A.locals;(0,l.render)(r.createElement(u,null),window.document.querySelector("#app-container"))})(); \ No newline at end of file