Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@abtasty/cognitivediscountmaker

Package Overview
Dependencies
Maintainers
22
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abtasty/cognitivediscountmaker - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

2

dist/main.js

@@ -1,1 +0,1 @@

!function(){"use strict";var e="https://turing-engine.appspot.com/api/v1",t=function(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")},n=function(n,i,r,o){var a=n.map(function(e){return Object.assign(e,{vas:(t=e,n=t.newPrice,i=t.oldPrice,[i-n,Math.round(100*(1-n/i))])});var t,n,i});return Promise.all(a.map(function(n){var a=n.vas,c=n.newPrice,l=n.oldPrice,s=n.discountContainerElem,d=n.conversionElem;return function(n){var i=n.cid,r=n.vas,o=n.vid,a=n.caid,c=n.c;return console.log("cognitiveModule :","Call Turing Engine : ",{cid:i,vas:r,vid:o,caid:a,c:c}),new Promise(function(n,l){return fetch(e+"/suggest?"+t({cid:i,vid:o,caid:a,c:c,vas:r}),{method:"GET"}).then(function(e){return n(e.json())})})}({cid:i,vid:r,vas:"perc,value",caid:o,c:l.toString().replace(".","d")+"_"+c.toString().replace(".","d")}).then(function(e){var t=e.va;return{vas:a,newPrice:c,oldPrice:l,va:t,selectedVa:"value"===t?a[0]:a[1]+"%",discountContainerElem:s,conversionElem:d}})}))},i=function(n,i,r){!function(n){var i=n.cid,r=n.vid,o=n.caid,a=n.c,c=n.a;fetch(e+"/convert?"+t({cid:i,vid:r,caid:o,c:a,a:c}),{method:"GET"})}({cid:n,vid:i,c:r,caid:"undefined"!=typeof TEST_ID?TEST_ID:n,a:0})};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}("abtasty-modal{display:none;z-index:1000000}abtasty-modal,abtasty-modal__underlay{position:fixed;top:0;left:0;width:100%;height:100%}abtasty-modal__underlay{background-color:rgba(0,0,0,.5);cursor:pointer}.abtasty-modal__area{top:0;left:0;right:0;width:auto;margin:10px!important;max-height:70%;z-index:100;position:relative;background-color:#fff;border:3px solid #fff;box-shadow:0 0 10px #666;-moz-box-shadow:#666 0 0 10px;-webkit-box-shadow:#666 0 0 10px;text-align:left}.abtasty-modal__close{float:right!important;font-size:44px;font-weight:300;background:transparent;border:0;color:#bbb;font-family:Helvetica Neue,Helvetica,Arial,sans-serif!important;line-height:32px!important;margin-right:5px;cursor:pointer}.abtasty-modal__text{padding:20px;font-family:Open Sans,sans-serif!important;color:#000}.abtasty-modal__title{text-align:left;width:auto;font-size:31px!important;font-weight:500;line-height:1.1;margin-bottom:10px}.abtasty-modal__text p{margin:0 0 10px!important;font-size:15px;font-weight:300}@media (min-width:630px){.abtasty-modal__area{width:600px;margin:150px auto!important}}");var r=function(e){var t=Object.prototype.hasOwnProperty;function n(e,i){return Array.isArray(e)?function(e,t){for(var i,r="",o="",c=Array.isArray(t),l=0;l<e.length;l++)(i=n(e[l]))&&(c&&t[l]&&(i=a(i)),r=r+o+i,o=" ");return r}(e,i):e&&"object"==typeof e?function(e){var n="",i="";for(var r in e)r&&e[r]&&t.call(e,r)&&(n=n+i+r,i=" ");return n}(e):e||""}function i(e){if(!e)return"";if("object"==typeof e){var n="";for(var i in e)t.call(e,i)&&(n=n+i+":"+e[i]+";");return n}return e+""}function r(e,t,n,i){if(!1===t||null==t||!t&&("class"===e||"style"===e))return"";if(!0===t)return" "+(i?e:e+'="'+e+'"');var r=typeof t;return"object"!==r&&"function"!==r||"function"!=typeof t.toJSON||(t=t.toJSON()),"string"==typeof t||(t=JSON.stringify(t),n||-1===t.indexOf('"'))?(n&&(t=a(t))," "+e+'="'+t+'"'):" "+e+"='"+t.replace(/'/g,"&#39;")+"'"}e.merge=function e(t,n){if(1===arguments.length){for(var r=t[0],o=1;o<t.length;o++)r=e(r,t[o]);return r}for(var a in n)if("class"===a){var c=t[a]||[];t[a]=(Array.isArray(c)?c:[c]).concat(n[a]||[])}else if("style"===a){var c=i(t[a]);c=c&&";"!==c[c.length-1]?c+";":c;var l=i(n[a]);l=l&&";"!==l[l.length-1]?l+";":l,t[a]=c+l}else t[a]=n[a];return t},e.classes=n,e.style=i,e.attr=r,e.attrs=function(e,o){var a="";for(var c in e)if(t.call(e,c)){var l=e[c];if("class"===c){l=n(l),a=r(c,l,!1,o)+a;continue}"style"===c&&(l=i(l)),a+=r(c,l,!1,o)}return a};var o=/["&<>]/;function a(e){var t=""+e,n=o.exec(t);if(!n)return e;var i,r,a,c="";for(i=n.index,r=0;i<t.length;i++){switch(t.charCodeAt(i)){case 34:a="&quot;";break;case 38:a="&amp;";break;case 60:a="&lt;";break;case 62:a="&gt;";break;default:continue}r!==i&&(c+=t.substring(r,i)),r=i+1,c+=a}return r!==i?c+t.substring(r,i):c}return e.escape=a,e.rethrow=function e(t,n,i,r){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||r))throw t.message+=" on line "+i,t;try{r=r||require("fs").readFileSync(n,"utf8")}catch(n){e(t,null,i)}var o=3,a=r.split("\n"),c=Math.max(i-o,0),l=Math.min(a.length,i+o);var o=a.slice(c,l).map(function(e,t){var n=t+c+1;return(n==i?" > ":" ")+n+"| "+e}).join("\n");t.path=n;t.message=(n||"Pug")+":"+i+"\n"+o+"\n\n"+t.message;throw t},e}({});function o(e){var t,n="";try{var i={},o=e||{};(function(e,i){n=(n=(n+="<div>")+'<div class="abtasty-price_tag"'+r.attr("style",r.style(i),!0,!0)+">")+r.escape(null==(t=e)?"":t)+"</div></div>"}).call(this,"price"in o?o.price:"undefined"!=typeof price?price:void 0,"style"in o?o.style:"undefined"!=typeof style?style:void 0)}catch(e){r.rethrow(e,void 0,void 0,i[void 0])}return n}var a=function(e){var t=window.document,n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.right<=(window.innerWidth||t.documentElement.clientWidth)&&n.bottom<=(window.innerHeight||t.documentElement.clientHeight)&&null!==e.offsetParent},c=function(e){var t=e.replace(/[^0-9,.€$£¥]+/g,"");return t=t.replace(/[€$£¥,]+/g,"."),parseFloat(t)},l=window.ABTasty&&window.ABTasty.visitor&&window.ABTasty.visitor.id||"noVisitorId",s=window.ABTasty&&window.ABTasty.accountSettings&&window.ABTasty.accountSettings.identifier||"noIdentifier",d=function(e){var t=e.target.dataset.abtastyDiscount||"";t&&i(s,l,t.indexOf("%")>-1?"perc":"value")},u=function(e){var t=e.oldPriceSelector,i=e.newPriceSelector,r=e.discountContainerSelector,u=e.conversionSelector,f=e.displayAction,p=e.styleReplace,v=e.currency,y=e.backgroundColor,g=e.textColor,m=e.fontSize,h=e.fontWeight,b=e.borderColor,w=e.borderWidth,x=e.borderRadius,S=e.DEBUG_ALGO_MODE;console.log("cognitiveModule :","oldPriceSelector : ",t),console.log("cognitiveModule :","newPriceSelector : ",i),console.log("cognitiveModule :","discountContainerSelector : ",r);var E=function(e){for(var t=e.oldPriceSelector,n=e.newPriceSelector,i=e.discountContainerSelector,r=e.conversionSelector,o=e.displayAction,l=[],s=document.querySelectorAll(t),d=0;d<s.length;d++){var u=s.item(d);a(u)&&!u.dataset.abtastyDiscountHandled&&(console.log("cognitiveModule :","isElementInViewport : ",u),l.push(u))}var f=[n,i,r],p=[];return l.forEach(function(e){for(var t=function(e,t){for(var n=e,i=!1;!i&&n.parentElement;)(i=t.every(function(e){return n.querySelector(e)}))||(n=n.parentElement);return n}(e,f),a=[],l=t.querySelectorAll(n),s=0;s<l.length;s++){var d=l.item(s);null!==d.offsetParent&&a.push(d)}if(!(a.length>1||t.querySelector(".abtasty-price_tag"))){var u=t.querySelector(r),v=t.querySelector(i);if(!u.dataset.abtastyDiscount){"replace"===o&&(v.setAttribute("data-abtasty-old-visibility",v.style.visibility),v.style.visibility="hidden"),e.setAttribute("data-abtasty-discount-handled","1");var y=c(e.textContent),g=c(a[0].textContent);Number.isNaN(y)||Number.isNaN(g)||p.push({oldPrice:y,newPrice:g,discountContainerElem:v,conversionElem:u})}}}),p}({oldPriceSelector:t,newPriceSelector:i,discountContainerSelector:r,conversionSelector:u,displayAction:f});return console.log("cognitiveModule :","Products where apply script : ",E),document.querySelectorAll(u).forEach(function(e){e.removeEventListener("click",d),e.addEventListener("click",d)}),function(e,t,i){var r="undefined"!=typeof TEST_ID?TEST_ID:e;return 0===i.length?Promise.resolve([]):n(i,e,t,r)}(s,l,E).then(function(e){return function(e){var t=e.productsArray,n=e.displayAction,i=e.styleReplace,r=e.currency,a=e.style;t.forEach(function(e){if(e.selectedVa){var t=e.selectedVa.toString(),c=t.indexOf("%")>-1?"- "+t:"- "+(Math.round(100*t)/100).toFixed(2)+r;switch(e.conversionElem.setAttribute("data-abtasty-discount",e.oldPrice+"_"+e.newPrice),n){case"replace":if(i){var l=o({price:c,style:a});e.discountContainerElem.innerHTML=l}else e.discountContainerElem.textContent=c;break;case"append":var s=o({price:c,style:a});e.discountContainerElem.innerHTML+=s}void 0!==e.discountContainerElem.dataset.abtastyOldVisibility&&(e.discountContainerElem.style.visibility=e.discountContainerElem.dataset.abtastyOldVisibility||"inherit")}})}({productsArray:e,displayAction:f,styleReplace:p,currency:v,debugDisplay:S,style:{"background-color":y,color:g,"font-size":m+"px","font-weight":h,"border-color":b,"border-width":w+"px","border-radius":x+"px","border-style":"solid",display:"inline-block",padding:"5px"}})})};console.log("cognitiveModule :","File loaded"),function e(){console.log("cognitiveModule :","Datas : ",DATA),u(DATA).then(function(){window.setTimeout(function(){e()},100)})}()}();
!function(){"use strict";var t="https://turing-engine.appspot.com/api/v1",e=function(t){return Object.keys(t).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])}).join("&")},n=function(n,r,i,o){var a=n.map(function(t){return Object.assign(t,{vas:(e=t,n=e.newPrice,r=e.oldPrice,[r-n,Math.round(100*(1-n/r))])});var e,n,r});return Promise.all(a.map(function(n){var a=n.vas,c=n.newPrice,s=n.oldPrice,l=n.discountContainerElem,d=n.conversionElem;return function(n){var r=n.cid,i=n.vas,o=n.vid,a=n.caid,c=n.c;return new Promise(function(n,s){return fetch(t+"/suggest?"+e({cid:r,vid:o,caid:a,c:c,vas:i}),{method:"GET"}).then(function(t){return n(t.json())})})}({cid:r,vid:i,vas:"perc,value",caid:o,c:s.toString().replace(".","d")+"_"+c.toString().replace(".","d")}).then(function(t){var e=t.va;return{vas:a,newPrice:c,oldPrice:s,va:e,selectedVa:"value"===e?a[0]:a[1]+"%",discountContainerElem:l,conversionElem:d}})}))},r=function(n,r,i){!function(n){var r=n.cid,i=n.vid,o=n.caid,a=n.c,c=n.a;fetch(t+"/convert?"+e({cid:r,vid:i,caid:o,c:a,a:c}),{method:"GET"})}({cid:n,vid:r,c:i,caid:"undefined"!=typeof TEST_ID?TEST_ID:n,a:0})};!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}("abtasty-modal{display:none;z-index:1000000}abtasty-modal,abtasty-modal__underlay{position:fixed;top:0;left:0;width:100%;height:100%}abtasty-modal__underlay{background-color:rgba(0,0,0,.5);cursor:pointer}.abtasty-modal__area{top:0;left:0;right:0;width:auto;margin:10px!important;max-height:70%;z-index:100;position:relative;background-color:#fff;border:3px solid #fff;box-shadow:0 0 10px #666;-moz-box-shadow:#666 0 0 10px;-webkit-box-shadow:#666 0 0 10px;text-align:left}.abtasty-modal__close{float:right!important;font-size:44px;font-weight:300;background:transparent;border:0;color:#bbb;font-family:Helvetica Neue,Helvetica,Arial,sans-serif!important;line-height:32px!important;margin-right:5px;cursor:pointer}.abtasty-modal__text{padding:20px;font-family:Open Sans,sans-serif!important;color:#000}.abtasty-modal__title{text-align:left;width:auto;font-size:31px!important;font-weight:500;line-height:1.1;margin-bottom:10px}.abtasty-modal__text p{margin:0 0 10px!important;font-size:15px;font-weight:300}@media (min-width:630px){.abtasty-modal__area{width:600px;margin:150px auto!important}}");var i=function(t){var e=Object.prototype.hasOwnProperty;function n(t,r){return Array.isArray(t)?function(t,e){for(var r,i="",o="",c=Array.isArray(e),s=0;s<t.length;s++)(r=n(t[s]))&&(c&&e[s]&&(r=a(r)),i=i+o+r,o=" ");return i}(t,r):t&&"object"==typeof t?function(t){var n="",r="";for(var i in t)i&&t[i]&&e.call(t,i)&&(n=n+r+i,r=" ");return n}(t):t||""}function r(t){if(!t)return"";if("object"==typeof t){var n="";for(var r in t)e.call(t,r)&&(n=n+r+":"+t[r]+";");return n}return t+""}function i(t,e,n,r){if(!1===e||null==e||!e&&("class"===t||"style"===t))return"";if(!0===e)return" "+(r?t:t+'="'+t+'"');var i=typeof e;return"object"!==i&&"function"!==i||"function"!=typeof e.toJSON||(e=e.toJSON()),"string"==typeof e||(e=JSON.stringify(e),n||-1===e.indexOf('"'))?(n&&(e=a(e))," "+t+'="'+e+'"'):" "+t+"='"+e.replace(/'/g,"&#39;")+"'"}t.merge=function t(e,n){if(1===arguments.length){for(var i=e[0],o=1;o<e.length;o++)i=t(i,e[o]);return i}for(var a in n)if("class"===a){var c=e[a]||[];e[a]=(Array.isArray(c)?c:[c]).concat(n[a]||[])}else if("style"===a){var c=r(e[a]);c=c&&";"!==c[c.length-1]?c+";":c;var s=r(n[a]);s=s&&";"!==s[s.length-1]?s+";":s,e[a]=c+s}else e[a]=n[a];return e},t.classes=n,t.style=r,t.attr=i,t.attrs=function(t,o){var a="";for(var c in t)if(e.call(t,c)){var s=t[c];if("class"===c){s=n(s),a=i(c,s,!1,o)+a;continue}"style"===c&&(s=r(s)),a+=i(c,s,!1,o)}return a};var o=/["&<>]/;function a(t){var e=""+t,n=o.exec(e);if(!n)return t;var r,i,a,c="";for(r=n.index,i=0;r<e.length;r++){switch(e.charCodeAt(r)){case 34:a="&quot;";break;case 38:a="&amp;";break;case 60:a="&lt;";break;case 62:a="&gt;";break;default:continue}i!==r&&(c+=e.substring(i,r)),i=r+1,c+=a}return i!==r?c+e.substring(i,r):c}return t.escape=a,t.rethrow=function t(e,n,r,i){if(!(e instanceof Error))throw e;if(!("undefined"==typeof window&&n||i))throw e.message+=" on line "+r,e;try{i=i||require("fs").readFileSync(n,"utf8")}catch(n){t(e,null,r)}var o=3,a=i.split("\n"),c=Math.max(r-o,0),s=Math.min(a.length,r+o);var o=a.slice(c,s).map(function(t,e){var n=e+c+1;return(n==r?" > ":" ")+n+"| "+t}).join("\n");e.path=n;e.message=(n||"Pug")+":"+r+"\n"+o+"\n\n"+e.message;throw e},t}({});function o(t){var e,n="";try{var r={},o=t||{};(function(t,r){n=(n=(n+="<div>")+'<div class="abtasty-price_tag"'+i.attr("style",i.style(r),!0,!0)+">")+i.escape(null==(e=t)?"":e)+"</div></div>"}).call(this,"price"in o?o.price:"undefined"!=typeof price?price:void 0,"style"in o?o.style:"undefined"!=typeof style?style:void 0)}catch(t){i.rethrow(t,void 0,void 0,r[void 0])}return n}var a=function(t){var e=window.document,n=t.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.right<=(window.innerWidth||e.documentElement.clientWidth)&&n.bottom<=(window.innerHeight||e.documentElement.clientHeight)&&null!==t.offsetParent},c=function(t){var e=t.replace(/[^0-9,.€$£¥]+/g,"");return e=e.replace(/[€$£¥,]+/g,"."),parseFloat(e)},s=window.ABTasty&&window.ABTasty.visitor&&window.ABTasty.visitor.id||"noVisitorId",l=window.ABTasty&&window.ABTasty.accountSettings&&window.ABTasty.accountSettings.identifier||"noIdentifier",d=function(t){var e=t.target.dataset.abtastyDiscount||"";e&&r(l,s,e.indexOf("%")>-1?"perc":"value")},u=function(t){var e=t.oldPriceSelector,r=t.newPriceSelector,i=t.discountContainerSelector,u=t.conversionSelector,f=t.displayAction,p=t.styleReplace,y=t.currency,v=t.currencyPosition,m=t.backgroundColor,h=t.textColor,g=t.fontSize,b=t.fontWeight,w=t.borderColor,x=t.borderWidth,S=t.borderRadius,E=t.DEBUG_ALGO_MODE,A=function(t){for(var e=t.oldPriceSelector,n=t.newPriceSelector,r=t.discountContainerSelector,i=t.conversionSelector,o=t.displayAction,s=[],l=document.querySelectorAll(e),d=0;d<l.length;d++){var u=l.item(d);a(u)&&!u.dataset.abtastyDiscountHandled&&s.push(u)}var f=[n,r,i],p=[];return s.forEach(function(t){for(var e=function(t,e){for(var n=t,r=!1;!r&&n.parentElement;)(r=e.every(function(t){return n.querySelector(t)}))||(n=n.parentElement);return n}(t,f),a=[],s=e.querySelectorAll(n),l=0;l<s.length;l++){var d=s.item(l);null!==d.offsetParent&&a.push(d)}if(!(a.length>1||e.querySelector(".abtasty-price_tag"))){var u=e.querySelector(i),y=e.querySelector(r);if(!u.dataset.abtastyDiscount){"replace"===o&&(y.setAttribute("data-abtasty-old-visibility",y.style.visibility),y.style.visibility="hidden"),t.setAttribute("data-abtasty-discount-handled","1");var v=c(t.textContent),m=c(a[0].textContent);Number.isNaN(v)||Number.isNaN(m)||p.push({oldPrice:v,newPrice:m,discountContainerElem:y,conversionElem:u})}}}),p}({oldPriceSelector:e,newPriceSelector:r,discountContainerSelector:i,conversionSelector:u,displayAction:f});return document.querySelectorAll(u).forEach(function(t){t.removeEventListener("click",d),t.addEventListener("click",d)}),function(t,e,r){var i="undefined"!=typeof TEST_ID?TEST_ID:t;return 0===r.length?Promise.resolve([]):n(r,t,e,i)}(l,s,A).then(function(t){return function(t){var e=t.productsArray,n=t.displayAction,r=t.styleReplace,i=t.currency,a=t.currencyPosition,c=t.style;e.forEach(function(t){if(t.selectedVa){var e=t.selectedVa.toString(),s=e.indexOf("%")>-1?"- "+e:"- "+("before"===a?i:"")+(Math.round(100*e)/100).toFixed(0)+("after"===a?i:"");switch(t.conversionElem.setAttribute("data-abtasty-discount",t.oldPrice+"_"+t.newPrice),n){case"replace":if(r){var l=o({price:s,style:c});t.discountContainerElem.innerHTML=l}else t.discountContainerElem.textContent=s;break;case"append":var d=o({price:s,style:c});t.discountContainerElem.innerHTML+=d}void 0!==t.discountContainerElem.dataset.abtastyOldVisibility&&(t.discountContainerElem.style.visibility=t.discountContainerElem.dataset.abtastyOldVisibility||"inherit")}})}({productsArray:t,displayAction:f,styleReplace:p,currency:y,currencyPosition:v,debugDisplay:E,style:{"background-color":m,color:h,"font-size":g+"px","font-weight":b,"border-color":w,"border-width":x+"px","border-radius":S+"px","border-style":"solid",display:"inline-block",padding:"5px"}})})};!function t(){u(DATA).then(function(){window.setTimeout(function(){t()},100)})}()}();
{
"name": "@abtasty/cognitivediscountmaker",
"description": "A simple widget",
"version": "1.0.6",
"version": "1.0.7",
"main": "dist/main.js",

@@ -11,4 +11,3 @@ "form": "dist/form.js",

],
"repository": "abtasty/widget",
"author": "Guillaume",
"author": "GuillaumeJ",
"license": "MIT",

@@ -15,0 +14,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc