PageSourceSearch

https://www.ushorizon.com/_ui/addons/smarteditaddon/shared/common/js/webApplicationInjector.js

js ushorizon.com collected 2026-10-06 02:06:47 UTC 7,498 bytes, 3 lines download raw bytes

1/*! For license information please see webApplicationInjector.js.LICENSE.txt
2Version: 0.0.5 */
3(()=>{var t={887(t,e,n){var r,o,a;a=function(){var t,e,n=document,r=n.getElementsByTagName("head")[0],o="push",a="readyState",i="onreadystatechange",s={},c={},d={},l={};function p(t,e){for(var n=0,r=t.length;n<r;++n)if(!e(t[n]))return!1;return 1}function u(t,e){p(t,function(t){return e(t),1})}function m(e,n,r){e=e[o]?e:[e];var a=n&&n.call,i=a?n:r,g=a?e.join(""):n,h=e.length;function w(t){return t.call?t():s[t]}function E(){if(! --h)for(var t in s[g]=1,i&&i(),d)p(t.split("|"),w)&&!u(d[t],w)&&(d[t]=[])}return setTimeout(function(){u(e,function e(n,r){return null===n?E():(r||/^https?:\/\//.test(n)||!t||(n=-1===n.indexOf(".js")?t+n+".js":t+n),l[n]?(g&&(c[g]=1),2==l[n]?E():setTimeout(function(){e(n,!0)},0)):(l[n]=1,g&&(c[g]=1),void f(n,E)))})},0),m}function f(t,o){var s,c=n.createElement("script");c.onload=c.onerror=c[i]=function(){c[a]&&!/^c|loade/.test(c[a])||s||(c.onload=c[i]=null,s=1,l[t]=2,o())},c.async=1,c.src=e?t+(-1===t.indexOf("?")?"?":"&")+e:t,r.insertBefore(c,r.lastChild)}return m.get=f,m.order=function(t,e,n){!function r(o){o=t.shift(),t.length?m(o,r):m(o,e,n)}()},m.path=function(e){t=e},m.urlArgs=function(t){e=t},m.ready=function(t,e,n){t=t[o]?t:[t];var r,a=[];return!u(t,function(t){s[t]||a[o](t)})&&p(t,function(t){return s[t]})?e():(r=t.join("|"),d[r]=d[r]||[],d[r][o](e),n&&n(a)),m},m.done=function(t){m([null],t)},m},t.exports?t.exports=a():void 0===(o="function"==typeof(r=a)?r.call(e,n,e,t):r)||(t.exports=o)}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var a=e[r]={exports:{}};return t[r](a,a.exports,n),a.exports}(()=>{"use strict";class t{static DEFAULT_HEARTBEAT_INTERVAL="500";static startSendingHeartBeatToIframe(e){const n=t.getHeartBeatInterval(e);setInterval(()=>{parent.postMessage({pk:Math.random(),gatewayId:"heartBeatGateway",eventId:"heartBeat",data:{location:document.location.href}},"*")},n)}static getHeartBeatInterval(e){return parseInt(e.getAttribute("data-smartedit-heart-beat-interval")||t.DEFAULT_HEARTBEAT_INTERVAL,10)}}var e=n(887);class r{static webappScriptId="smartedit-injector";static webappScriptName="webApplicationInjector";static smarteditMainCssId="smarteditMainCss";static getWebappScriptElementFromDocument(t){if(t.currentScript){if(!(t.currentScript instanceof HTMLScriptElement))throw new Error("getWebappScriptElementFromDocument() found non html script element");return t.currentScript}const e=t.querySelector(`script#${r.webappScriptId}`);if(e)return e;const n=t.querySelectorAll(`script[src*=${r.webappScriptName}]`);if(1!==n.length)throw new Error(`SmartEdit unable to load - invalid ${r.webappScriptName} script tag`);return n.item(0)}static extractQueryParameter(t,e){const n={};return t.replace(/([?&])([^&=]+)=([^&]+)?/g,(t,e,r,o)=>(n[r]=o,"")),n[e]}static injectJS(t,e=0){t.length&&e<t.length&&r.getScriptJs()(t[e],function(){r.injectJS(t,e+1)})}static injectCSS(t,e){if(!t||!e)return;const n=t.getElementsByTagName("link");for(const r of e)if(!this.findLinkByHref(n,r)){const e=document.createElement("link");e.rel="stylesheet",e.type="text/css",e.href=r,t.appendChild(e)}}static injectThemeCSS(t,e){if(!e||e.length<2)return;const n=t.getElementsByTagName("link");for(let r=0;r<e.length;r++)if(!this.findLinkByHref(n,e[r])){const n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.id=`themeCss${r}`,n.href=e[r],t.appendChild(n)}}static findLinkByHref(t,e){let n=0,r=t.item(n),o=!1;for(;null!==r;){if(r.href===e){o=!0;break}n++,r=t.item(n)}return o}static updateThemeCss(t){if(!t||t.length<2)return;const e=document.getElementById("themeCss0"),n=document.getElementById("themeCss1");e&&n&&(e.href=t[0],n.href=t[1])}static getScriptJs(){const t=e,n="function"==typeof t?t:t?.default;if("function"!=typeof n)throw new Error("scriptjs module does not export a function");return n}}class o{static whitelistingConfigRegex=new RegExp(/^(([-*a-zA-Z0-9]+[.])*([-a-zA-Z0-9]+[.]))?[-a-zA-Z0-9]+(:[0-9]{1,5})$/);static allowOriginAttributeName="data-smartedit-allow-origin";static allowOriginQueryParamName="allow-origin";static whitelistingErrorMsg="\n\t\tAllowed whitelist characters are a-z, A-Z, 0-9, -, period, or *\n\t\tThe wildcard * can be used to represent a prefixed domain, Good example: *.domain.com:80\n\t\tbut not a suffix or port, Bad examples: subdomain.*.com subdomain.domain.com:*.\n\t\tEvery whitelisting must contain a specific port.\n\t";static convertWhitelistingToRegexp(t){return(t=t||[]).map(t=>{const e=t.trim();if(o.whitelistingConfigRegex.test(e)){const t=["^","$"].join(e.replace(/\./g,"\\.").replace(/\*/g,"[-a-zA-Z0-9]*"));return new RegExp(t)}throw new Error(o.whitelistingErrorMsg)})}static getWhitelistFromScriptElement(t,e){let n=[o.getSanitizedHostFromLocation(e.location)];const a=t.getAttribute(o.allowOriginAttributeName)||"";a&&(n=n.concat(a.split(",")));let i="";const s=e.document.createElement("a");s.href=t.src;const c=r.extractQueryParameter(s.search,o.allowOriginQueryParamName);return c&&(i=decodeURI(c),i&&i.split(",").forEach(t=>n.push(t))),n}static isAllowed(t,e,n){if(!/^(https?:)\/\/([-.a-zA-Z0-9]+(:[0-9]{1,5})?)$/.test(t))return!1;const r=e.document.createElement("a");return r.href=t,("https:"!==e.location.protocol||"https:"===r.protocol)&&n.some(t=>(t.lastIndex=0,t.test(o.getSanitizedHostFromLocation(r))))}static getSanitizedHostFromLocation(t){const e=t.port||("https"===t.protocol.replace(/:/g,"")?"443":"80");return`${t.hostname}:${e}`}}const a="smartEditBootstrap",i=r.getWebappScriptElementFromDocument(document);if(!i)throw new Error("Unable to location webappInjector script");const s=o.getWhitelistFromScriptElement(i,window),c=o.convertWhitelistingToRegexp(s);function d(){window.removeEventListener("load",d),window.removeEventListener("storefrontload",d),parent.postMessage({pk:Math.random(),gatewayId:a,eventId:"bootstrapSmartEdit",data:{location:document.location.href}},"*")}function l(t){parent.postMessage({gatewayId:a,eventId:"promiseAcknowledgement",data:{pk:t}},"*")}function p(t){parent.postMessage({gatewayId:a,eventId:"promiseReturn",data:{pk:t,type:"success"}},"*")}parent.postMessage({pk:Math.random(),gatewayId:a,eventId:"loading",data:{location:document.location.href,version:"0.0.5"}},"*"),window.addEventListener("load",d),window.addEventListener("storefrontload",d),window.addEventListener("message",function(t){const e=t.data.gatewayId===a,n=e&&"bundle"===t.data.eventId,i=e&&"theme"===t.data.eventId;if(!n&&!i)return;if(!o.isAllowed(t.origin,window,c))throw new Error(t.origin+" is not allowed to override this storefront.");if(n)return void function(t,e){if(window.smartedit=window.smartedit||{},l(t),e){const t=document.getElementsByTagName("head")[0];!function(t){if(!t.properties)return;for(const e in t.properties)t.properties.hasOwnProperty(e)&&(window.smartedit[e]=t.properties[e])}(e),function(t){if(!(t.js&&t.js.length>0))return;let e;e="string"==typeof t.js[0]?t.js:t.js.filter(t=>!t.namespaceToCheck||!window[t.namespaceToCheck]).map(t=>t.src);r.injectJS(e)}(e),e.css&&e.css.length>0&&r.injectCSS(t,e.css),e.themeCss&&e.themeCss.length>0&&r.injectThemeCSS(t,e.themeCss)}p(t)}(t.data.pk,t.data.data.resources);i&&(s=t.data.pk,d=t.data.data.resources,l(s),r.updateThemeCss(d.themeCss),p(s));var s,d},!1),window.onbeforeunload=function(){parent.postMessage({pk:Math.random(),gatewayId:a,eventId:"unloading",data:{location:document.location.href}},"*")},t.startSendingHeartBeatToIframe(i)})()})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.