Last active
October 11, 2024 10:18
-
-
Save DRFR0ST/c91df3081ab35713b8af611f15598255 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(()=>{"use strict";const t=document.querySelector("#sharefox-embed-script"),e=document.querySelectorAll(".sharefox-embed");for(const o of e){const e=o.getAttribute("data-shop")||t?.getAttribute("data-shop"),s=o.getAttribute("data-path"),a=t?.getAttribute("data-hostname")||`https://${e}.mysharefox.com`,n=new URL(`${a}/embeds/${s}`);if("product"===s){const t=o.getAttribute("data-id"),e=o.getAttribute("data-slug");if(!t){console.error("Missing data-id attribute for product embed.");continue}if(!e){console.error("Missing data-slug attribute for product embed.");continue}n.searchParams.append("id",t),n.searchParams.append("slug",e)}else if("products-popular"===s){const t=o.getAttribute("data-volume");t&&n.searchParams.append("volume",t)}else if("search-advanced"===s||"search"===s){const t=o.getAttribute("data-products-path")||"products";n.searchParams.append("productsPath",t)}const i=o.getAttribute("id"),d=document.createElement("iframe");d.setAttribute("id",i||r()),d.setAttribute("src",n.toString());const u=o.getAttribute("style"),c=o.getAttribute("class");d.setAttribute("style",`${u}; border: 0; outline: 0; overflow: hidden;`),d.setAttribute("class",c),d.onload=function(){console.log("Finished loading Sharefox embed.")},(o.parentNode||document.body).insertBefore(d,o.nextSibling),o.remove()}function r(){const t=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment