diff --git a/package.json b/package.json index 2b575dd..ac83dbd 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "snyk-api-and-web-record-sequence", - "version": "1.1.0", + "version": "1.2.0", "description": "Snyk API & Web Record login/sequence", "license": "MIT", "scripts": { diff --git a/src/manifest-firefox.json b/src/manifest-firefox.json index 4660825..080126f 100755 --- a/src/manifest-firefox.json +++ b/src/manifest-firefox.json @@ -1,6 +1,6 @@ { "name": "Snyk API & Web Sequence Recorder", - "version": "1.1.0", + "version": "1.2.0", "browser_specific_settings": { "gecko": { "id": "sequence-recorder@probely.com", diff --git a/src/pages/Content/modules/collectEvents.js b/src/pages/Content/modules/collectEvents.js index 75ae049..3438765 100644 --- a/src/pages/Content/modules/collectEvents.js +++ b/src/pages/Content/modules/collectEvents.js @@ -19,6 +19,59 @@ const lastNodes = { }; let stoMouseover = false; +let pendingInput = null; +let flushedInput = null; +const keystrokeBuffers = new WeakMap(); + +function getEffectiveValue(element) { + const domValue = element.value; + if (domValue && domValue.trim()) { + return domValue; + } + return keystrokeBuffers.get(element) || domValue; +} + +function isBufferedValue(element) { + const domValue = element.value; + return !(domValue && domValue.trim()) && keystrokeBuffers.has(element); +} + +function isCanvasSurface(element) { + if (element.nodeName.toLowerCase() === 'canvas') return true; + if (element.shadowRoot) { + try { + if (element.shadowRoot.querySelector('canvas')) return true; + } catch (ex) { /* ignore */ } + } + for (const child of element.children || []) { + if (child.shadowRoot) { + try { + if (child.shadowRoot.querySelector('canvas')) return true; + } catch (ex) { /* ignore */ } + } + } + return false; +} + +function getStableInputSelector(element, doc) { + const dynamicPatterns = ['focus', 'highlight', 'editable', 'caret']; + const classes = Array.from(element.classList || []).filter((cls) => { + const lower = cls.toLowerCase(); + return !dynamicPatterns.some((p) => lower.includes(p)) && !/^[0-9]/.test(cls); + }); + for (const cls of classes) { + const sel = '.' + cls; + try { + const matches = doc.querySelectorAll(sel); + if (matches.length === 1 && matches[0] === element) { + return sel; + } + } catch (ex) { + // ignore + } + } + return null; +} export function interceptEvents(event, doc, ifrSelector, callback) { let hasKeyReturn = false; @@ -110,6 +163,26 @@ export function interceptEvents(event, doc, ifrSelector, callback) { if (type === 'click') { lastNodes.click = tgt; + if (pendingInput && pendingInput.element !== tgt && callback) { + const useBuffer = isBufferedValue(pendingInput.element); + const fillEvent = { + ...pendingInput.oEventBase, + type: useBuffer ? 'bfill_value' : 'fill_value', + value: getEffectiveValue(pendingInput.element), + frame: pendingInput.frame, + }; + if (useBuffer) { + const stableSel = getStableInputSelector(pendingInput.element, doc); + if (stableSel) { + fillEvent.css = stableSel; + } + } + callback({ messageType: 'events', event: { ...fillEvent } }); + keystrokeBuffers.delete(pendingInput.element); + flushedInput = pendingInput.element; + pendingInput = null; + } + if ( lastNodes.return === lastNodes.change && tgt !== lastNodes.return && @@ -134,7 +207,7 @@ export function interceptEvents(event, doc, ifrSelector, callback) { } } let typeStr = 'click'; - if (nodeName === 'canvas') { + if (isCanvasSurface(tgt)) { const rect = tgt.getBoundingClientRect(); const x = event.clientX - rect.left; const y = event.clientY - rect.top; @@ -261,6 +334,16 @@ export function interceptEvents(event, doc, ifrSelector, callback) { lastNodes.keydown = tgt; if (['input', 'textarea'].indexOf(nodeName) > -1) { oNodes[tgt] = tgt.value; + pendingInput = { element: tgt, oEventBase: { ...oEventBase }, frame: ifrSelector }; + if (event.key && event.key.length === 1) { + const buf = keystrokeBuffers.get(tgt) || ''; + keystrokeBuffers.set(tgt, buf + event.key); + } else if (event.key === 'Backspace') { + const buf = keystrokeBuffers.get(tgt) || ''; + if (buf.length > 0) { + keystrokeBuffers.set(tgt, buf.slice(0, -1)); + } + } } if ( nodeName === 'input' && @@ -271,15 +354,30 @@ export function interceptEvents(event, doc, ifrSelector, callback) { hasKeyReturn = true; // lastSelectorWithReturn = selector; lastNodes.return = tgt; + const useBuffer = isBufferedValue(tgt); oEventToSend = { ...oEventBase, - type: 'fill_value', - value: tgt.value, + type: useBuffer ? 'bfill_value' : 'fill_value', + value: getEffectiveValue(tgt), frame: ifrSelector, }; + if (useBuffer) { + const stableSel = getStableInputSelector(tgt, doc); + if (stableSel) { + oEventToSend.css = stableSel; + } + } + keystrokeBuffers.delete(tgt); } } else if (type === 'blur') { lastNodes.blur = tgt; + if (tgt === flushedInput) { + flushedInput = null; + return; + } + if (pendingInput && pendingInput.element === tgt) { + pendingInput = null; + } if (['input', 'textarea'].indexOf(nodeName) > -1) { oNodes[tgt] = tgt.value; if (tgt === lastNodes.return) { @@ -292,12 +390,20 @@ export function interceptEvents(event, doc, ifrSelector, callback) { ) { return; } + const useBuffer = isBufferedValue(tgt); oEventToSend = { ...oEventBase, - type: 'fill_value', - value: tgt.value, + type: useBuffer ? 'bfill_value' : 'fill_value', + value: getEffectiveValue(tgt), frame: ifrSelector, }; + if (useBuffer) { + const stableSel = getStableInputSelector(tgt, doc); + if (stableSel) { + oEventToSend.css = stableSel; + } + } + keystrokeBuffers.delete(tgt); } } else if (type === 'change') { lastNodes.change = tgt; diff --git a/src/pages/Popup/Popup.jsx b/src/pages/Popup/Popup.jsx index 159958e..84b4fb0 100644 --- a/src/pages/Popup/Popup.jsx +++ b/src/pages/Popup/Popup.jsx @@ -3,7 +3,7 @@ import logo from '../../assets/img/logo_probely.svg'; import help from '../../assets/img/help.svg'; import './Popup.css'; -const helpURL = 'https://help.probely.com/en/articles/5402869-how-to-record-a-sequence-with-probely-s-sequence-recorder-plugin'; +const helpURL = 'https://docs.snyk.io/scan-fix-and-prevent/scan-with-snyk/snyk-api-web/configure-targets/configure-web-targets/use-sequence-recorder'; const Popup = (props) => { // 🔴 @@ -11,22 +11,22 @@ const Popup = (props) => { const [isRecording, setIsRecording] = useState(false); const [startURL, setStartURL] = useState(''); const [recordingData, setRecordingData] = useState([]); - const [copyStatus, setCopyStatus] = useState({status: false, error: false, msg: 'Successfully copied to clipboard'}); + const [copyStatus, setCopyStatus] = useState({ status: false, error: false, msg: 'Successfully copied to clipboard' }); useEffect(() => { if (chrome && chrome.storage) { chrome.storage.sync.get(['isRecording'], (data) => { const recording = data.isRecording; - if(recording) { + if (recording) { setIsRecording(true); (chrome.action || chrome.browserAction).setBadgeText({ text: '🔴', - }, () => {}); + }, () => { }); } else { setIsRecording(false); (chrome.action || chrome.browserAction).setBadgeText({ text: '', - }, () => {}); + }, () => { }); } }); chrome.runtime.onMessage.addListener((data, sender, sendResponse) => { @@ -51,8 +51,8 @@ const Popup = (props) => { if (chrome) { (chrome.action || chrome.browserAction).setBadgeText({ text: '🔴', - }, () => {}); - chrome.storage.sync.set({isRecording: true}, () => { + }, () => { }); + chrome.storage.sync.set({ isRecording: true }, () => { chrome.runtime.sendMessage({ messageType: 'start', event: { @@ -63,7 +63,7 @@ const Popup = (props) => { url: startURL, }, }); - chrome.tabs.create({active: true, url: startURL}, (aa) => { + chrome.tabs.create({ active: true, url: startURL }, (aa) => { }); }); } @@ -74,15 +74,15 @@ const Popup = (props) => { if (chrome) { (chrome.action || chrome.browserAction).setBadgeText({ text: '', - }, () => {}); - chrome.storage.sync.set({isRecording: false}, () => { + }, () => { }); + chrome.storage.sync.set({ isRecording: false }, () => { askForRecordingData(); - chrome.tabs.query({active: true, currentWindow: true}, (tabs) => { + chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { if (tabs && tabs.length) { const curTab = tabs[0]; chrome.tabs.remove(curTab.id); - chrome.tabs.create({active: true, url: './review.html'}, (aa) => { + chrome.tabs.create({ active: true, url: './review.html' }, (aa) => { }); } }); @@ -126,7 +126,7 @@ const Popup = (props) => { msg: 'Successfully copied to clipboard' }); setTimeout(() => { - setCopyStatus({status: false, error: false, msg: ''}); + setCopyStatus({ status: false, error: false, msg: '' }); }, 3000); } else { setCopyStatus({ @@ -135,7 +135,7 @@ const Popup = (props) => { msg: 'Error on copy to clipboard' }); setTimeout(() => { - setCopyStatus({status: false, error: false, msg: ''}); + setCopyStatus({ status: false, error: false, msg: '' }); }, 5000); } } @@ -144,7 +144,7 @@ const Popup = (props) => { function onClickDownload() { var blob = new Blob([JSON.stringify(recordingData, null, 2)], { type: "text/plain;charset=utf-8" - }); + }); var a = document.createElement('a'); a.download = 'snyk-api-and-web-recording.json'; a.rel = 'noopener'; @@ -169,7 +169,7 @@ const Popup = (props) => { function onClickHelpLink(ev) { ev.preventDefault(); - chrome.tabs.create({active: true, url: helpURL}, (aa) => { + chrome.tabs.create({ active: true, url: helpURL }, (aa) => { }); } @@ -181,8 +181,8 @@ const Popup = (props) => {

- Use this plugin to record a sequence of steps to be followed by Snyk API & Web during a scan.{' '} - When you finish recording, upload the script to your target settings. + Use this plugin to record a sequence of steps to be followed by Snyk API & Web during a scan.{' '} + When you finish recording, upload the script to your target settings.

{

{isRecording ? null - : + : <> { }
- {isRecording ? + {isRecording ? // eslint-disable-next-line jsx-a11y/anchor-is-valid

{ onClickStartStopRecording(ev, false); }} >Stop recording

- : + :
- : null} + : null}
{copyStatus.status ? -
{copyStatus.msg}
- : null} +
{copyStatus.msg}
+ : null}
- {recordingData.length ? + {recordingData.length ? - : null} + : null}
); }; diff --git a/src/pages/Review/Review.jsx b/src/pages/Review/Review.jsx index 0c0e0d2..62eb2c1 100644 --- a/src/pages/Review/Review.jsx +++ b/src/pages/Review/Review.jsx @@ -8,7 +8,7 @@ const Review = (props) => { const [recordingDataOriginal, setRecordingDataOriginal] = useState([]); const [recordingData, setRecordingData] = useState([]); const [recordingDataDownload, setRecordingDataDownload] = useState([]); - const [copyStatus, setCopyStatus] = useState({status: false, error: false, msg: 'Successfully copied to clipboard'}); + const [copyStatus, setCopyStatus] = useState({ status: false, error: false, msg: 'Successfully copied to clipboard' }); const [showAdvanced, setShowAdvanced] = useState(true); useEffect(() => { @@ -66,7 +66,7 @@ const Review = (props) => { msg: 'Successfully copied to clipboard' }); setTimeout(() => { - setCopyStatus({status: false, error: false, msg: ''}); + setCopyStatus({ status: false, error: false, msg: '' }); }, 3000); } else { setCopyStatus({ @@ -75,7 +75,7 @@ const Review = (props) => { msg: 'Error on copy to clipboard' }); setTimeout(() => { - setCopyStatus({status: false, error: false, msg: ''}); + setCopyStatus({ status: false, error: false, msg: '' }); }, 5000); } } @@ -148,7 +148,7 @@ const Review = (props) => { } function onChangeTableUrlType(ev, idx) { - + const tgt = ev.target; const tmp = JSON.parse(JSON.stringify(recordingData)); const val = tgt.value; @@ -156,7 +156,7 @@ const Review = (props) => { // if (idx === 0 && val !== 'force' && val !== 'loggedin_start_url') { // return; // } - + // For now only allow "force" and "ignore" if (idx === 0 && val !== 'force') { return; @@ -236,6 +236,7 @@ const Review = (props) => { let newType = type; switch (type) { case 'fill_value': + case 'bfill_value': newType = 'fill with value'; break; case 'press_key': @@ -265,59 +266,59 @@ const Review = (props) => {
{recordingData && recordingData.length ? - <> -

You can copy or download the recorded information here or through the plugin window.

-
- - -
-
- { onChangeReviewAdvanced(ev); }} - /> -
-

After saving your sequence, make sure to import it to your target settings at Snyk API & Web, so it is followed during scans.

- - :

No data has been recorded

} + <> +

You can copy or download the recorded information here or through the plugin window.

+
+ + +
+
+ { onChangeReviewAdvanced(ev); }} + /> +
+

After saving your sequence, make sure to import it to your target settings at Snyk API & Web, so it is followed during scans.

+ + :

No data has been recorded

}
{copyStatus.status ? -
{copyStatus.msg}
- : null} +
{copyStatus.msg}
+ : null}
{recordingData && recordingData.length && showAdvanced ? <>

You can review the steps recorded below.{' '} - Note that changing the sequence in any way could prevent the crawler from successfully replaying it.

+ Note that changing the sequence in any way could prevent the crawler from successfully replaying it.

Some tips:

- {recordingData.length ? + {recordingData.length ? - : null} + : null}
); }; diff --git a/test-build-firefox/contentScript.bundle.js b/test-build-firefox/contentScript.bundle.js index c0943a6..9a6eafe 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 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 +(()=>{"use strict";let e,t;function n(n,r){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,...r},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=o(n,"all",(()=>o(n,"two",(()=>o(n,"one",(()=>o(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 o(t,n,o){let l=null,i=[],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(i.push(t),i.length>=e.seedMinLength&&(l=r(i,o),l))break;a=a.parentElement,g++}return l||(l=r(i,o)),!l&&o?o():l}function r(t,n){const o=w(y(t));if(o.length>e.threshold)return n?n():null;for(let e of o)if(a(e))return e;return null}function l(e){let t=e[0],n=t.name;for(let o=1;o ${n}`:`${e[o].name} ${n}`,t=e[o]}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 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 o=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&o++,n!==e);)n=n.nextSibling;return o}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)=>i(e)-i(t)))}function*v(t,n,o={counter:0,visited:new Map}){if(t.length>2&&t.length>e.optimizedMinLength)for(let r=1;re.maxNumberOfTries)return;o.counter+=1;const i=[...t];i.splice(r,1);const s=l(i);if(o.visited.has(s))return;a(i)&&b(i,n)&&(yield i,o.visited.set(s,!0),yield*v(i,n,o))}}function b(e,n){return t.querySelector(l(e))===n}function N(e,t){let n="",o=null,r=!1;try{if(o=e.nodeName&&"string"==typeof e.nodeName?e.nodeName.toLowerCase():null,!o)return null;n=`${o}`,e.getAttribute("id")&&(n=`${n}#${CSS.escape(e.getAttribute("id"))}`,r=!0);const t=["data-test-id","data-testid","data-test","data-cy"];if(e.matches(t.map((e=>`[${e}]`)).join(",")))for(const o of t){const t=e.getAttribute(o);if(t){n=`${n}[${o}="${CSS.escape(t)}"]`;break}}if(["input","button","textarea","select","option"].includes(o)){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&&!r&&(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,o=e,r=[];for(;o;){let e=0,n=o.previousElementSibling;for(;n;)n.nodeName===o.nodeName&&e++,n=n.previousElementSibling;let l=o.nodeName.toLowerCase();e>0&&(l=l+"["+(e+1)+"]"),o!==t&&r.unshift(l),o=o.parentNode}if(n="/"+r.join("/"),function(e,t){const n=t.evaluate(e,t,null,XPathResult.ANY_TYPE,null),o=n.iterateNext();return o}(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 A=!1,$=null,k=null;const L=new WeakMap;function T(e){const t=e.value;return t&&t.trim()?t:L.get(e)||t}function x(e){const t=e.value;return!(t&&t.trim())&&L.has(e)}function M(e,t){const n=["focus","highlight","editable","caret"],o=Array.from(e.classList||[]).filter((e=>{const t=e.toLowerCase();return!n.some((e=>t.includes(e)))&&!/^[0-9]/.test(e)}));for(const n of o){const o="."+n;try{const n=t.querySelectorAll(o);if(1===n.length&&n[0]===e)return o}catch(e){}}return null}function O(e,t){let n;var o;let r,l;function i(e,t,o){let l=null;const i=[];let s=e,c=0;for(;s&&s!==r.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(i.push(e),i.length>=r.seedMinLength&&(l=a(i,o),l))break;s=s.parentElement,c++}return l||(l=a(i,o)),l}function a(e,t){const n=N(b(e));if(n.length>r.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 o=1;o ${n}`:`${e[o].name} ${n}`,t=e[o]}return n}function c(e){return e.map((e=>e.penalty)).reduce(((e,t)=>e+t),0)}function u(e){switch(l.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&&r.idName(t)?{name:`#${k(t,{isIdentifier:!0})}`,penalty:0}:null}function d(e){return Array.from(e.attributes).filter((e=>r.attr(e.name,e.value))).map((e=>({name:"["+k(e.name,{isIdentifier:!0})+'="'+k(e.value)+'"]',penalty:.5})))}function m(e){return Array.from(e.classList).filter(r.className).map((e=>({name:"."+k(e,{isIdentifier:!0}),penalty:1})))}function h(e){const t=e.tagName.toLowerCase();return r.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 o=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&o++,n!==e);)n=n.nextSibling;return o}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 0c(e)-c(t)))}function E(e,t){return l.querySelector(s(e))===t}(o=n||(n={}))[o.All=0]="All",o[o.Two=1]="Two",o[o.One=2]="One";const S=/[ -,\.\/:-@\[-\^`\{-~]/,C=/[ -,\.\/:-@\[\]\^`\{-~]/,A=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,$={escapeEverything:!1,isIdentifier:!1,quotes:"single",wrap:!1};function k(e,t={}){const n=Object.assign(Object.assign({},$),t);"single"!==n.quotes&&"double"!==n.quotes&&(n.quotes="single");const o="double"==n.quotes?'"':"'",r=n.isIdentifier,l=e.charAt(0);let i="",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};r=Object.assign(Object.assign({},L),t),l=function(e,t){return e.nodeType===Node.DOCUMENT_NODE?e:e===t.root?e.ownerDocument:e}(r.root,L);let T=i(e,n.All,(()=>i(e,n.Two,(()=>i(e,n.One)))));if(T){const t=N(function*e(t,n,o={counter:0,visited:new Map}){if(2r.optimizedMinLength)for(let l=1;lr.maxNumberOfTries)return;o.counter+=1;const i=[...t];i.splice(l,1);const a=s(i);if(o.visited.has(a))return;u(i)&&E(i,n)&&(yield i,o.visited.set(a,!0),yield*e(i,n,o))}}(T,e));return 0{if(!l.isRecording)return;let i=!1,a=null;function s(e){e&&"mouseover"===e.type&&!i||function(e,t,o,r){let l=!1,i=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))),i=s>-1?a[0]:e.target;const c=e.type;let u=null,f=null;if(!i||!i.getAttribute)return;u=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 o=e.closest("svg");o&&(e=o);const r=["data-test-id","data-testid","data-test","data-cy"];if(e.matches(r.map((e=>`[${e}]`)).join(",")))return e;if(e.parentNode.matches(r.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 h=null;try{h=E(m,t)}catch(e){}s>-1&&(h="/html/node/shadow");let p={timestamp:(new Date).getTime(),css:d||i,xpath:h||""},g={};if("click"===c){if(C.click=i,$&&$.element!==i&&r){const e=x($.element),n={...$.oEventBase,type:e?"bfill_value":"fill_value",value:T($.element),frame:$.frame};if(e){const e=M($.element,t);e&&(n.css=e)}r({messageType:"events",event:{...n}}),L.delete($.element),k=$.element,$=null}if(!(C.return!==C.change||i===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=i.getAttribute("for");if(e&&document.getElementById(e))return}let l="click";if(function(e){if("canvas"===e.nodeName.toLowerCase())return!0;if(e.shadowRoot)try{if(e.shadowRoot.querySelector("canvas"))return!0}catch(e){}for(const t of e.children||[])if(t.shadowRoot)try{if(t.shadowRoot.querySelector("canvas"))return!0}catch(e){}return!1}(i)){const t=i.getBoundingClientRect(),n={x:e.clientX-t.left,y:e.clientY-t.top,width:t.width,height:t.height};p={...p,coords:n},l="bclick"}if(g={...p,type:l,value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:o},"bclick"===l&&s>-1&&a){const e=a[s].host;if(e){let o=null;try{o=N(e)}catch(e){}if(!o)try{o=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){}o&&(g.shadow_host_css=o)}}}else if("dblclick"===c)C.dblclick=i,g={...p,type:"dblclick",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:o};else if("contextmenu"===c)C.contextmenu=i,g={...p,type:"contextmenu",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:o};else if("focus"===c);else if("mouseover"===c)A&&(clearTimeout(A),A=!1),A=setTimeout((()=>{A=!1,C.mouseover=i,g={...p,type:"mouseover",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:o},g&&g.type&&r&&r({messageType:"events",event:{...g}})}),500);else if("mouseout"===c);else if("keydown"===c){if(C.keydown=i,["input","textarea"].indexOf(u)>-1)if(S[i]=i.value,$={element:i,oEventBase:{...p},frame:o},e.key&&1===e.key.length){const t=L.get(i)||"";L.set(i,t+e.key)}else if("Backspace"===e.key){const e=L.get(i)||"";e.length>0&&L.set(i,e.slice(0,-1))}if("input"===u&&13===e.keyCode){l=!0,C.return=i;const e=x(i);if(g={...p,type:e?"bfill_value":"fill_value",value:T(i),frame:o},e){const e=M(i,t);e&&(g.css=e)}L.delete(i)}}else if("blur"===c){if(C.blur=i,i===k)return void(k=null);if($&&$.element===i&&($=null),["input","textarea"].indexOf(u)>-1){if(S[i]=i.value,i===C.return)return void(C.return=null);if("input"===u&&("submit"===i.type||"button"===i.type||"image"===i.type))return;const e=x(i);if(g={...p,type:e?"bfill_value":"fill_value",value:T(i),frame:o},e){const e=M(i,t);e&&(g.css=e)}L.delete(i)}}else if("change"===c)if(C.change=i,"input"===u)"checkbox"!==f&&"radio"!==f||(g={...p,type:"change",subtype:"check",checked:i.checked,frame:o});else if("select"===u)if(i.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 o of t)if(o.contentWindow===e.source){n=!0;break}if(!n)return;const o={...e.data.obj},r=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=O(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&&o.event){const t=[e,...r];o.event.frame=t.join(" >>> "),chrome.runtime.sendMessage(o)}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 o of t)if(o.contentWindow===e.source){n=!0;break}if(!n)return;const o=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=O(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&&o.push(t),window.parent.postMessage({source:"event-from-iframe",obj:e.data.obj,framePath:o},"*");break}}})),l.isRecording&&(t=!0,e=document.title,function(){if(!t)return document.title=`${e}`,r=!1,void(o&&(clearInterval(o),o=!1));o=setInterval((()=>{r?(document.title=`${e}`,r=!1):(document.title=`🔴 ${e}`,r=!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)=>{i=!0,a&&(clearTimeout(a),a=null),a=setTimeout((()=>{i=!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 4660825..080126f 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.1.0", + "version": "1.2.0", "browser_specific_settings": { "gecko": { "id": "sequence-recorder@probely.com", diff --git a/test-build-firefox/popup.bundle.js b/test-build-firefox/popup.bundle.js index fd23c0e..bd1bead 100644 --- a/test-build-firefox/popup.bundle.js +++ b/test-build-firefox/popup.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 w(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 k(e){if(g=!1,w(e),!h)if(null!==r(s))h=!0,F(S);else{var t=r(c);null!==t&&R(k,t.startTime-e)}}function S(e,n){h=!1,g&&(g=!1,y(_),_=-1),m=!0;var a=p;try{for(w(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),w(n)}else l(s);d=r(s)}if(null!==d)var i=!0;else{var f=r(c);null!==f&&R(k,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,C=null,_=-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(_),_=-1):g=!0,R(k,a-o))):(e.sortIndex=u,n(s,e),h||m||(h=!0,F(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",o=n.p+"d2b15a3067409e19ad1e.svg";var u=n(72),i=n.n(u),s=n(825),c=n.n(s),f=n(659),d=n.n(f),p=n(56),m=n.n(p),h=n(159),g=n.n(h),v=n(113),y=n.n(v),b=n(346),w={};w.styleTagTransform=y(),w.setAttributes=m(),w.insert=d().bind(null,"head"),w.domAPI=c(),w.insertStyleElement=g();i()(b.A,w);b.A&&b.A.locals&&b.A.locals;const k="https://help.probely.com/en/articles/5402869-how-to-record-a-sequence-with-probely-s-sequence-recorder-plugin",S=e=>{const[t,n]=(0,r.useState)(!1),[l,u]=(0,r.useState)(""),[i,s]=(0,r.useState)([]),[c,f]=(0,r.useState)({status:!1,error:!1,msg:"Successfully copied to clipboard"});function d(){chrome.runtime.sendMessage({messageType:"give_recording_data"})}function p(e,t){n(t),!0===t?(s([]),chrome&&((chrome.action||chrome.browserAction).setBadgeText({text:"🔴"},(()=>{})),chrome.storage.sync.set({isRecording:!0},(()=>{chrome.runtime.sendMessage({messageType:"start",event:{type:"goto",timestamp:(new Date).getTime(),windowWidth:null,windowHeight:null,url:l}}),chrome.tabs.create({active:!0,url:l},(e=>{}))})))):(e&&e.preventDefault(),chrome&&((chrome.action||chrome.browserAction).setBadgeText({text:""},(()=>{})),chrome.storage.sync.set({isRecording:!1},(()=>{d(),chrome.tabs.query({active:!0,currentWindow:!0},(e=>{if(e&&e.length){const t=e[0];chrome.tabs.remove(t.id),chrome.tabs.create({active:!0,url:"./review.html"},(e=>{}))}}))}))))}return(0,r.useEffect)((()=>{chrome&&chrome.storage&&(chrome.storage.sync.get(["isRecording"],(e=>{e.isRecording?(n(!0),(chrome.action||chrome.browserAction).setBadgeText({text:"🔴"},(()=>{}))):(n(!1),(chrome.action||chrome.browserAction).setBadgeText({text:""},(()=>{})))})),chrome.runtime.onMessage.addListener(((e,t,n)=>{"recording_data"===e.messageType&&s(e.recordingData||[])})),d())}),[]),r.createElement("div",{className:"App"},r.createElement("header",{className:"App-header"},r.createElement("img",{src:a,className:"App-logo",alt:"logo"}),r.createElement("h1",{className:"App-title"},"Sequence Recorder")),r.createElement("div",{className:"App-container"},r.createElement("p",null,"Use this plugin to record a sequence of steps to be followed by Snyk API & Web during a scan."," ","When you finish recording, upload the script to your target settings."),r.createElement("p",{className:"help-container"},r.createElement("a",{href:k,className:"help-link",rel:"noreferrer",onClick:e=>{!function(e){e.preventDefault(),chrome.tabs.create({active:!0,url:k},(e=>{}))}(e)}},"Usage instructions ",r.createElement("img",{src:o,className:"help-logo",alt:"Help"})))),r.createElement("form",{method:"post",action:"#",className:"url-form",onSubmit:e=>{!function(e){e.preventDefault(),l&&p(null,!0)}(e)}},r.createElement("div",{className:"input-url-container"},t?null:r.createElement(r.Fragment,null,r.createElement("label",{className:"start_url_label",htmlFor:"start_url"},"Type the start URL to be recorded"),r.createElement("input",{type:"url",name:"start_url",id:"start_url",required:!0,className:"start-url",placeholder:"https://your-target-url.com/",autoComplete:"off",pattern:"^https?://.*",onChange:e=>{!function(e){const t=e.target;u(t.value)}(e)},value:l}))),r.createElement("div",{className:"buttons-container"},t?r.createElement("p",null,r.createElement("a",{href:"#",className:"App-button",onClick:e=>{p(e,!1)}},"Stop recording")):r.createElement("button",{type:"submit",className:"App-button"},i.length?"Start new recording":"Start recording"))),!t&&i.length?r.createElement(r.Fragment,null,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("div",{className:"buttons-container"},r.createElement("button",{type:"button",className:"App-button",onClick:()=>{!function(){var e=new Blob([JSON.stringify(i,null,2)],{type:"text/plain;charset=utf-8"}),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){var 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:"buttons-container"},r.createElement("button",{type:"button",className:"App-button App-button-secondary",onClick:()=>{chrome&&(chrome.runtime.sendMessage({messageType:"clear"}),s([]))}},"Clear recording data"))):null,r.createElement("div",{className:"copy-status-container"},c.status?r.createElement("div",{className:c.error?"copy-status error":"copy-status success"},c.msg):null),i.length?r.createElement("textarea",{id:"input-copy-to-clipboard",defaultValue:JSON.stringify(i,null,2)}):null)};var x=n(812),E={};E.styleTagTransform=y(),E.setAttributes=m(),E.insert=d().bind(null,"head"),E.domAPI=c(),E.insertStyleElement=g();i()(x.A,E);x.A&&x.A.locals&&x.A.locals;(0,l.render)(r.createElement(S,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 w(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 k(e){if(g=!1,w(e),!h)if(null!==r(s))h=!0,F(S);else{var t=r(c);null!==t&&R(k,t.startTime-e)}}function S(e,n){h=!1,g&&(g=!1,y(_),_=-1),m=!0;var a=p;try{for(w(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),w(n)}else l(s);d=r(s)}if(null!==d)var i=!0;else{var f=r(c);null!==f&&R(k,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,C=null,_=-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(_),_=-1):g=!0,R(k,a-o))):(e.sortIndex=u,n(s,e),h||m||(h=!0,F(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",o=n.p+"d2b15a3067409e19ad1e.svg";var u=n(72),i=n.n(u),s=n(825),c=n.n(s),f=n(659),d=n.n(f),p=n(56),m=n.n(p),h=n(159),g=n.n(h),v=n(113),y=n.n(v),b=n(346),w={};w.styleTagTransform=y(),w.setAttributes=m(),w.insert=d().bind(null,"head"),w.domAPI=c(),w.insertStyleElement=g();i()(b.A,w);b.A&&b.A.locals&&b.A.locals;const k="https://docs.snyk.io/scan-fix-and-prevent/scan-with-snyk/snyk-api-web/configure-targets/configure-web-targets/use-sequence-recorder",S=e=>{const[t,n]=(0,r.useState)(!1),[l,u]=(0,r.useState)(""),[i,s]=(0,r.useState)([]),[c,f]=(0,r.useState)({status:!1,error:!1,msg:"Successfully copied to clipboard"});function d(){chrome.runtime.sendMessage({messageType:"give_recording_data"})}function p(e,t){n(t),!0===t?(s([]),chrome&&((chrome.action||chrome.browserAction).setBadgeText({text:"🔴"},(()=>{})),chrome.storage.sync.set({isRecording:!0},(()=>{chrome.runtime.sendMessage({messageType:"start",event:{type:"goto",timestamp:(new Date).getTime(),windowWidth:null,windowHeight:null,url:l}}),chrome.tabs.create({active:!0,url:l},(e=>{}))})))):(e&&e.preventDefault(),chrome&&((chrome.action||chrome.browserAction).setBadgeText({text:""},(()=>{})),chrome.storage.sync.set({isRecording:!1},(()=>{d(),chrome.tabs.query({active:!0,currentWindow:!0},(e=>{if(e&&e.length){const t=e[0];chrome.tabs.remove(t.id),chrome.tabs.create({active:!0,url:"./review.html"},(e=>{}))}}))}))))}return(0,r.useEffect)((()=>{chrome&&chrome.storage&&(chrome.storage.sync.get(["isRecording"],(e=>{e.isRecording?(n(!0),(chrome.action||chrome.browserAction).setBadgeText({text:"🔴"},(()=>{}))):(n(!1),(chrome.action||chrome.browserAction).setBadgeText({text:""},(()=>{})))})),chrome.runtime.onMessage.addListener(((e,t,n)=>{"recording_data"===e.messageType&&s(e.recordingData||[])})),d())}),[]),r.createElement("div",{className:"App"},r.createElement("header",{className:"App-header"},r.createElement("img",{src:a,className:"App-logo",alt:"logo"}),r.createElement("h1",{className:"App-title"},"Sequence Recorder")),r.createElement("div",{className:"App-container"},r.createElement("p",null,"Use this plugin to record a sequence of steps to be followed by Snyk API & Web during a scan."," ","When you finish recording, upload the script to your target settings."),r.createElement("p",{className:"help-container"},r.createElement("a",{href:k,className:"help-link",rel:"noreferrer",onClick:e=>{!function(e){e.preventDefault(),chrome.tabs.create({active:!0,url:k},(e=>{}))}(e)}},"Usage instructions ",r.createElement("img",{src:o,className:"help-logo",alt:"Help"})))),r.createElement("form",{method:"post",action:"#",className:"url-form",onSubmit:e=>{!function(e){e.preventDefault(),l&&p(null,!0)}(e)}},r.createElement("div",{className:"input-url-container"},t?null:r.createElement(r.Fragment,null,r.createElement("label",{className:"start_url_label",htmlFor:"start_url"},"Type the start URL to be recorded"),r.createElement("input",{type:"url",name:"start_url",id:"start_url",required:!0,className:"start-url",placeholder:"https://your-target-url.com/",autoComplete:"off",pattern:"^https?://.*",onChange:e=>{!function(e){const t=e.target;u(t.value)}(e)},value:l}))),r.createElement("div",{className:"buttons-container"},t?r.createElement("p",null,r.createElement("a",{href:"#",className:"App-button",onClick:e=>{p(e,!1)}},"Stop recording")):r.createElement("button",{type:"submit",className:"App-button"},i.length?"Start new recording":"Start recording"))),!t&&i.length?r.createElement(r.Fragment,null,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("div",{className:"buttons-container"},r.createElement("button",{type:"button",className:"App-button",onClick:()=>{!function(){var e=new Blob([JSON.stringify(i,null,2)],{type:"text/plain;charset=utf-8"}),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){var 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:"buttons-container"},r.createElement("button",{type:"button",className:"App-button App-button-secondary",onClick:()=>{chrome&&(chrome.runtime.sendMessage({messageType:"clear"}),s([]))}},"Clear recording data"))):null,r.createElement("div",{className:"copy-status-container"},c.status?r.createElement("div",{className:c.error?"copy-status error":"copy-status success"},c.msg):null),i.length?r.createElement("textarea",{id:"input-copy-to-clipboard",defaultValue:JSON.stringify(i,null,2)}):null)};var x=n(812),E={};E.styleTagTransform=y(),E.setAttributes=m(),E.insert=d().bind(null,"head"),E.domAPI=c(),E.insertStyleElement=g();i()(x.A,E);x.A&&x.A.locals&&x.A.locals;(0,l.render)(r.createElement(S,null),window.document.querySelector("#app-container"))})(); \ No newline at end of file diff --git a/test-build-firefox/reviewpage.bundle.js b/test-build-firefox/reviewpage.bundle.js index 59fff4f..7e3c7fe 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;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 +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":case"bfill_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||"bfill_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 c0943a6..9a6eafe 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 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 +(()=>{"use strict";let e,t;function n(n,r){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,...r},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=o(n,"all",(()=>o(n,"two",(()=>o(n,"one",(()=>o(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 o(t,n,o){let l=null,i=[],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(i.push(t),i.length>=e.seedMinLength&&(l=r(i,o),l))break;a=a.parentElement,g++}return l||(l=r(i,o)),!l&&o?o():l}function r(t,n){const o=w(y(t));if(o.length>e.threshold)return n?n():null;for(let e of o)if(a(e))return e;return null}function l(e){let t=e[0],n=t.name;for(let o=1;o ${n}`:`${e[o].name} ${n}`,t=e[o]}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 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 o=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&o++,n!==e);)n=n.nextSibling;return o}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)=>i(e)-i(t)))}function*v(t,n,o={counter:0,visited:new Map}){if(t.length>2&&t.length>e.optimizedMinLength)for(let r=1;re.maxNumberOfTries)return;o.counter+=1;const i=[...t];i.splice(r,1);const s=l(i);if(o.visited.has(s))return;a(i)&&b(i,n)&&(yield i,o.visited.set(s,!0),yield*v(i,n,o))}}function b(e,n){return t.querySelector(l(e))===n}function N(e,t){let n="",o=null,r=!1;try{if(o=e.nodeName&&"string"==typeof e.nodeName?e.nodeName.toLowerCase():null,!o)return null;n=`${o}`,e.getAttribute("id")&&(n=`${n}#${CSS.escape(e.getAttribute("id"))}`,r=!0);const t=["data-test-id","data-testid","data-test","data-cy"];if(e.matches(t.map((e=>`[${e}]`)).join(",")))for(const o of t){const t=e.getAttribute(o);if(t){n=`${n}[${o}="${CSS.escape(t)}"]`;break}}if(["input","button","textarea","select","option"].includes(o)){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&&!r&&(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,o=e,r=[];for(;o;){let e=0,n=o.previousElementSibling;for(;n;)n.nodeName===o.nodeName&&e++,n=n.previousElementSibling;let l=o.nodeName.toLowerCase();e>0&&(l=l+"["+(e+1)+"]"),o!==t&&r.unshift(l),o=o.parentNode}if(n="/"+r.join("/"),function(e,t){const n=t.evaluate(e,t,null,XPathResult.ANY_TYPE,null),o=n.iterateNext();return o}(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 A=!1,$=null,k=null;const L=new WeakMap;function T(e){const t=e.value;return t&&t.trim()?t:L.get(e)||t}function x(e){const t=e.value;return!(t&&t.trim())&&L.has(e)}function M(e,t){const n=["focus","highlight","editable","caret"],o=Array.from(e.classList||[]).filter((e=>{const t=e.toLowerCase();return!n.some((e=>t.includes(e)))&&!/^[0-9]/.test(e)}));for(const n of o){const o="."+n;try{const n=t.querySelectorAll(o);if(1===n.length&&n[0]===e)return o}catch(e){}}return null}function O(e,t){let n;var o;let r,l;function i(e,t,o){let l=null;const i=[];let s=e,c=0;for(;s&&s!==r.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(i.push(e),i.length>=r.seedMinLength&&(l=a(i,o),l))break;s=s.parentElement,c++}return l||(l=a(i,o)),l}function a(e,t){const n=N(b(e));if(n.length>r.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 o=1;o ${n}`:`${e[o].name} ${n}`,t=e[o]}return n}function c(e){return e.map((e=>e.penalty)).reduce(((e,t)=>e+t),0)}function u(e){switch(l.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&&r.idName(t)?{name:`#${k(t,{isIdentifier:!0})}`,penalty:0}:null}function d(e){return Array.from(e.attributes).filter((e=>r.attr(e.name,e.value))).map((e=>({name:"["+k(e.name,{isIdentifier:!0})+'="'+k(e.value)+'"]',penalty:.5})))}function m(e){return Array.from(e.classList).filter(r.className).map((e=>({name:"."+k(e,{isIdentifier:!0}),penalty:1})))}function h(e){const t=e.tagName.toLowerCase();return r.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 o=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&o++,n!==e);)n=n.nextSibling;return o}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 0c(e)-c(t)))}function E(e,t){return l.querySelector(s(e))===t}(o=n||(n={}))[o.All=0]="All",o[o.Two=1]="Two",o[o.One=2]="One";const S=/[ -,\.\/:-@\[-\^`\{-~]/,C=/[ -,\.\/:-@\[\]\^`\{-~]/,A=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,$={escapeEverything:!1,isIdentifier:!1,quotes:"single",wrap:!1};function k(e,t={}){const n=Object.assign(Object.assign({},$),t);"single"!==n.quotes&&"double"!==n.quotes&&(n.quotes="single");const o="double"==n.quotes?'"':"'",r=n.isIdentifier,l=e.charAt(0);let i="",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};r=Object.assign(Object.assign({},L),t),l=function(e,t){return e.nodeType===Node.DOCUMENT_NODE?e:e===t.root?e.ownerDocument:e}(r.root,L);let T=i(e,n.All,(()=>i(e,n.Two,(()=>i(e,n.One)))));if(T){const t=N(function*e(t,n,o={counter:0,visited:new Map}){if(2r.optimizedMinLength)for(let l=1;lr.maxNumberOfTries)return;o.counter+=1;const i=[...t];i.splice(l,1);const a=s(i);if(o.visited.has(a))return;u(i)&&E(i,n)&&(yield i,o.visited.set(a,!0),yield*e(i,n,o))}}(T,e));return 0{if(!l.isRecording)return;let i=!1,a=null;function s(e){e&&"mouseover"===e.type&&!i||function(e,t,o,r){let l=!1,i=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))),i=s>-1?a[0]:e.target;const c=e.type;let u=null,f=null;if(!i||!i.getAttribute)return;u=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 o=e.closest("svg");o&&(e=o);const r=["data-test-id","data-testid","data-test","data-cy"];if(e.matches(r.map((e=>`[${e}]`)).join(",")))return e;if(e.parentNode.matches(r.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 h=null;try{h=E(m,t)}catch(e){}s>-1&&(h="/html/node/shadow");let p={timestamp:(new Date).getTime(),css:d||i,xpath:h||""},g={};if("click"===c){if(C.click=i,$&&$.element!==i&&r){const e=x($.element),n={...$.oEventBase,type:e?"bfill_value":"fill_value",value:T($.element),frame:$.frame};if(e){const e=M($.element,t);e&&(n.css=e)}r({messageType:"events",event:{...n}}),L.delete($.element),k=$.element,$=null}if(!(C.return!==C.change||i===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=i.getAttribute("for");if(e&&document.getElementById(e))return}let l="click";if(function(e){if("canvas"===e.nodeName.toLowerCase())return!0;if(e.shadowRoot)try{if(e.shadowRoot.querySelector("canvas"))return!0}catch(e){}for(const t of e.children||[])if(t.shadowRoot)try{if(t.shadowRoot.querySelector("canvas"))return!0}catch(e){}return!1}(i)){const t=i.getBoundingClientRect(),n={x:e.clientX-t.left,y:e.clientY-t.top,width:t.width,height:t.height};p={...p,coords:n},l="bclick"}if(g={...p,type:l,value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:o},"bclick"===l&&s>-1&&a){const e=a[s].host;if(e){let o=null;try{o=N(e)}catch(e){}if(!o)try{o=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){}o&&(g.shadow_host_css=o)}}}else if("dblclick"===c)C.dblclick=i,g={...p,type:"dblclick",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:o};else if("contextmenu"===c)C.contextmenu=i,g={...p,type:"contextmenu",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:o};else if("focus"===c);else if("mouseover"===c)A&&(clearTimeout(A),A=!1),A=setTimeout((()=>{A=!1,C.mouseover=i,g={...p,type:"mouseover",value:(i.value||i.textContent||"").trim().substr(0,20).replace(/\n/gi,""),frame:o},g&&g.type&&r&&r({messageType:"events",event:{...g}})}),500);else if("mouseout"===c);else if("keydown"===c){if(C.keydown=i,["input","textarea"].indexOf(u)>-1)if(S[i]=i.value,$={element:i,oEventBase:{...p},frame:o},e.key&&1===e.key.length){const t=L.get(i)||"";L.set(i,t+e.key)}else if("Backspace"===e.key){const e=L.get(i)||"";e.length>0&&L.set(i,e.slice(0,-1))}if("input"===u&&13===e.keyCode){l=!0,C.return=i;const e=x(i);if(g={...p,type:e?"bfill_value":"fill_value",value:T(i),frame:o},e){const e=M(i,t);e&&(g.css=e)}L.delete(i)}}else if("blur"===c){if(C.blur=i,i===k)return void(k=null);if($&&$.element===i&&($=null),["input","textarea"].indexOf(u)>-1){if(S[i]=i.value,i===C.return)return void(C.return=null);if("input"===u&&("submit"===i.type||"button"===i.type||"image"===i.type))return;const e=x(i);if(g={...p,type:e?"bfill_value":"fill_value",value:T(i),frame:o},e){const e=M(i,t);e&&(g.css=e)}L.delete(i)}}else if("change"===c)if(C.change=i,"input"===u)"checkbox"!==f&&"radio"!==f||(g={...p,type:"change",subtype:"check",checked:i.checked,frame:o});else if("select"===u)if(i.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 o of t)if(o.contentWindow===e.source){n=!0;break}if(!n)return;const o={...e.data.obj},r=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=O(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&&o.event){const t=[e,...r];o.event.frame=t.join(" >>> "),chrome.runtime.sendMessage(o)}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 o of t)if(o.contentWindow===e.source){n=!0;break}if(!n)return;const o=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=O(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&&o.push(t),window.parent.postMessage({source:"event-from-iframe",obj:e.data.obj,framePath:o},"*");break}}})),l.isRecording&&(t=!0,e=document.title,function(){if(!t)return document.title=`${e}`,r=!1,void(o&&(clearInterval(o),o=!1));o=setInterval((()=>{r?(document.title=`${e}`,r=!1):(document.title=`🔴 ${e}`,r=!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)=>{i=!0,a&&(clearTimeout(a),a=null),a=setTimeout((()=>{i=!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 9767b2b..b64e930 100644 --- a/test-build/manifest.json +++ b/test-build/manifest.json @@ -1 +1 @@ -{"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 +{"version":"1.2.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/popup.bundle.js b/test-build/popup.bundle.js index fd23c0e..bd1bead 100644 --- a/test-build/popup.bundle.js +++ b/test-build/popup.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 w(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 k(e){if(g=!1,w(e),!h)if(null!==r(s))h=!0,F(S);else{var t=r(c);null!==t&&R(k,t.startTime-e)}}function S(e,n){h=!1,g&&(g=!1,y(_),_=-1),m=!0;var a=p;try{for(w(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),w(n)}else l(s);d=r(s)}if(null!==d)var i=!0;else{var f=r(c);null!==f&&R(k,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,C=null,_=-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(_),_=-1):g=!0,R(k,a-o))):(e.sortIndex=u,n(s,e),h||m||(h=!0,F(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",o=n.p+"d2b15a3067409e19ad1e.svg";var u=n(72),i=n.n(u),s=n(825),c=n.n(s),f=n(659),d=n.n(f),p=n(56),m=n.n(p),h=n(159),g=n.n(h),v=n(113),y=n.n(v),b=n(346),w={};w.styleTagTransform=y(),w.setAttributes=m(),w.insert=d().bind(null,"head"),w.domAPI=c(),w.insertStyleElement=g();i()(b.A,w);b.A&&b.A.locals&&b.A.locals;const k="https://help.probely.com/en/articles/5402869-how-to-record-a-sequence-with-probely-s-sequence-recorder-plugin",S=e=>{const[t,n]=(0,r.useState)(!1),[l,u]=(0,r.useState)(""),[i,s]=(0,r.useState)([]),[c,f]=(0,r.useState)({status:!1,error:!1,msg:"Successfully copied to clipboard"});function d(){chrome.runtime.sendMessage({messageType:"give_recording_data"})}function p(e,t){n(t),!0===t?(s([]),chrome&&((chrome.action||chrome.browserAction).setBadgeText({text:"🔴"},(()=>{})),chrome.storage.sync.set({isRecording:!0},(()=>{chrome.runtime.sendMessage({messageType:"start",event:{type:"goto",timestamp:(new Date).getTime(),windowWidth:null,windowHeight:null,url:l}}),chrome.tabs.create({active:!0,url:l},(e=>{}))})))):(e&&e.preventDefault(),chrome&&((chrome.action||chrome.browserAction).setBadgeText({text:""},(()=>{})),chrome.storage.sync.set({isRecording:!1},(()=>{d(),chrome.tabs.query({active:!0,currentWindow:!0},(e=>{if(e&&e.length){const t=e[0];chrome.tabs.remove(t.id),chrome.tabs.create({active:!0,url:"./review.html"},(e=>{}))}}))}))))}return(0,r.useEffect)((()=>{chrome&&chrome.storage&&(chrome.storage.sync.get(["isRecording"],(e=>{e.isRecording?(n(!0),(chrome.action||chrome.browserAction).setBadgeText({text:"🔴"},(()=>{}))):(n(!1),(chrome.action||chrome.browserAction).setBadgeText({text:""},(()=>{})))})),chrome.runtime.onMessage.addListener(((e,t,n)=>{"recording_data"===e.messageType&&s(e.recordingData||[])})),d())}),[]),r.createElement("div",{className:"App"},r.createElement("header",{className:"App-header"},r.createElement("img",{src:a,className:"App-logo",alt:"logo"}),r.createElement("h1",{className:"App-title"},"Sequence Recorder")),r.createElement("div",{className:"App-container"},r.createElement("p",null,"Use this plugin to record a sequence of steps to be followed by Snyk API & Web during a scan."," ","When you finish recording, upload the script to your target settings."),r.createElement("p",{className:"help-container"},r.createElement("a",{href:k,className:"help-link",rel:"noreferrer",onClick:e=>{!function(e){e.preventDefault(),chrome.tabs.create({active:!0,url:k},(e=>{}))}(e)}},"Usage instructions ",r.createElement("img",{src:o,className:"help-logo",alt:"Help"})))),r.createElement("form",{method:"post",action:"#",className:"url-form",onSubmit:e=>{!function(e){e.preventDefault(),l&&p(null,!0)}(e)}},r.createElement("div",{className:"input-url-container"},t?null:r.createElement(r.Fragment,null,r.createElement("label",{className:"start_url_label",htmlFor:"start_url"},"Type the start URL to be recorded"),r.createElement("input",{type:"url",name:"start_url",id:"start_url",required:!0,className:"start-url",placeholder:"https://your-target-url.com/",autoComplete:"off",pattern:"^https?://.*",onChange:e=>{!function(e){const t=e.target;u(t.value)}(e)},value:l}))),r.createElement("div",{className:"buttons-container"},t?r.createElement("p",null,r.createElement("a",{href:"#",className:"App-button",onClick:e=>{p(e,!1)}},"Stop recording")):r.createElement("button",{type:"submit",className:"App-button"},i.length?"Start new recording":"Start recording"))),!t&&i.length?r.createElement(r.Fragment,null,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("div",{className:"buttons-container"},r.createElement("button",{type:"button",className:"App-button",onClick:()=>{!function(){var e=new Blob([JSON.stringify(i,null,2)],{type:"text/plain;charset=utf-8"}),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){var 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:"buttons-container"},r.createElement("button",{type:"button",className:"App-button App-button-secondary",onClick:()=>{chrome&&(chrome.runtime.sendMessage({messageType:"clear"}),s([]))}},"Clear recording data"))):null,r.createElement("div",{className:"copy-status-container"},c.status?r.createElement("div",{className:c.error?"copy-status error":"copy-status success"},c.msg):null),i.length?r.createElement("textarea",{id:"input-copy-to-clipboard",defaultValue:JSON.stringify(i,null,2)}):null)};var x=n(812),E={};E.styleTagTransform=y(),E.setAttributes=m(),E.insert=d().bind(null,"head"),E.domAPI=c(),E.insertStyleElement=g();i()(x.A,E);x.A&&x.A.locals&&x.A.locals;(0,l.render)(r.createElement(S,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 w(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 k(e){if(g=!1,w(e),!h)if(null!==r(s))h=!0,F(S);else{var t=r(c);null!==t&&R(k,t.startTime-e)}}function S(e,n){h=!1,g&&(g=!1,y(_),_=-1),m=!0;var a=p;try{for(w(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),w(n)}else l(s);d=r(s)}if(null!==d)var i=!0;else{var f=r(c);null!==f&&R(k,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,C=null,_=-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(_),_=-1):g=!0,R(k,a-o))):(e.sortIndex=u,n(s,e),h||m||(h=!0,F(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",o=n.p+"d2b15a3067409e19ad1e.svg";var u=n(72),i=n.n(u),s=n(825),c=n.n(s),f=n(659),d=n.n(f),p=n(56),m=n.n(p),h=n(159),g=n.n(h),v=n(113),y=n.n(v),b=n(346),w={};w.styleTagTransform=y(),w.setAttributes=m(),w.insert=d().bind(null,"head"),w.domAPI=c(),w.insertStyleElement=g();i()(b.A,w);b.A&&b.A.locals&&b.A.locals;const k="https://docs.snyk.io/scan-fix-and-prevent/scan-with-snyk/snyk-api-web/configure-targets/configure-web-targets/use-sequence-recorder",S=e=>{const[t,n]=(0,r.useState)(!1),[l,u]=(0,r.useState)(""),[i,s]=(0,r.useState)([]),[c,f]=(0,r.useState)({status:!1,error:!1,msg:"Successfully copied to clipboard"});function d(){chrome.runtime.sendMessage({messageType:"give_recording_data"})}function p(e,t){n(t),!0===t?(s([]),chrome&&((chrome.action||chrome.browserAction).setBadgeText({text:"🔴"},(()=>{})),chrome.storage.sync.set({isRecording:!0},(()=>{chrome.runtime.sendMessage({messageType:"start",event:{type:"goto",timestamp:(new Date).getTime(),windowWidth:null,windowHeight:null,url:l}}),chrome.tabs.create({active:!0,url:l},(e=>{}))})))):(e&&e.preventDefault(),chrome&&((chrome.action||chrome.browserAction).setBadgeText({text:""},(()=>{})),chrome.storage.sync.set({isRecording:!1},(()=>{d(),chrome.tabs.query({active:!0,currentWindow:!0},(e=>{if(e&&e.length){const t=e[0];chrome.tabs.remove(t.id),chrome.tabs.create({active:!0,url:"./review.html"},(e=>{}))}}))}))))}return(0,r.useEffect)((()=>{chrome&&chrome.storage&&(chrome.storage.sync.get(["isRecording"],(e=>{e.isRecording?(n(!0),(chrome.action||chrome.browserAction).setBadgeText({text:"🔴"},(()=>{}))):(n(!1),(chrome.action||chrome.browserAction).setBadgeText({text:""},(()=>{})))})),chrome.runtime.onMessage.addListener(((e,t,n)=>{"recording_data"===e.messageType&&s(e.recordingData||[])})),d())}),[]),r.createElement("div",{className:"App"},r.createElement("header",{className:"App-header"},r.createElement("img",{src:a,className:"App-logo",alt:"logo"}),r.createElement("h1",{className:"App-title"},"Sequence Recorder")),r.createElement("div",{className:"App-container"},r.createElement("p",null,"Use this plugin to record a sequence of steps to be followed by Snyk API & Web during a scan."," ","When you finish recording, upload the script to your target settings."),r.createElement("p",{className:"help-container"},r.createElement("a",{href:k,className:"help-link",rel:"noreferrer",onClick:e=>{!function(e){e.preventDefault(),chrome.tabs.create({active:!0,url:k},(e=>{}))}(e)}},"Usage instructions ",r.createElement("img",{src:o,className:"help-logo",alt:"Help"})))),r.createElement("form",{method:"post",action:"#",className:"url-form",onSubmit:e=>{!function(e){e.preventDefault(),l&&p(null,!0)}(e)}},r.createElement("div",{className:"input-url-container"},t?null:r.createElement(r.Fragment,null,r.createElement("label",{className:"start_url_label",htmlFor:"start_url"},"Type the start URL to be recorded"),r.createElement("input",{type:"url",name:"start_url",id:"start_url",required:!0,className:"start-url",placeholder:"https://your-target-url.com/",autoComplete:"off",pattern:"^https?://.*",onChange:e=>{!function(e){const t=e.target;u(t.value)}(e)},value:l}))),r.createElement("div",{className:"buttons-container"},t?r.createElement("p",null,r.createElement("a",{href:"#",className:"App-button",onClick:e=>{p(e,!1)}},"Stop recording")):r.createElement("button",{type:"submit",className:"App-button"},i.length?"Start new recording":"Start recording"))),!t&&i.length?r.createElement(r.Fragment,null,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("div",{className:"buttons-container"},r.createElement("button",{type:"button",className:"App-button",onClick:()=>{!function(){var e=new Blob([JSON.stringify(i,null,2)],{type:"text/plain;charset=utf-8"}),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){var 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:"buttons-container"},r.createElement("button",{type:"button",className:"App-button App-button-secondary",onClick:()=>{chrome&&(chrome.runtime.sendMessage({messageType:"clear"}),s([]))}},"Clear recording data"))):null,r.createElement("div",{className:"copy-status-container"},c.status?r.createElement("div",{className:c.error?"copy-status error":"copy-status success"},c.msg):null),i.length?r.createElement("textarea",{id:"input-copy-to-clipboard",defaultValue:JSON.stringify(i,null,2)}):null)};var x=n(812),E={};E.styleTagTransform=y(),E.setAttributes=m(),E.insert=d().bind(null,"head"),E.domAPI=c(),E.insertStyleElement=g();i()(x.A,E);x.A&&x.A.locals&&x.A.locals;(0,l.render)(r.createElement(S,null),window.document.querySelector("#app-container"))})(); \ No newline at end of file diff --git a/test-build/reviewpage.bundle.js b/test-build/reviewpage.bundle.js index 59fff4f..7e3c7fe 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;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 +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":case"bfill_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||"bfill_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