Skip to content

Instantly share code, notes, and snippets.

View husseyexplores's full-sized avatar
🐾
/ᐠ .ᆺ. ᐟ\ノ ( ̿–ᆺ ̿–)ノ

Hassan Usman husseyexplores

🐾
/ᐠ .ᆺ. ᐟ\ノ ( ̿–ᆺ ̿–)ノ
View GitHub Profile
@husseyexplores
husseyexplores / stamped-rating.html
Last active April 22, 2022 15:09
[Stamped Rating Badge] Custom element Api fallback
<script>
!function(){let t=document.getElementById("stamped-main-widget");let e=!1,a=["scroll","mousedown","wheel","DOMMouseScroll","mousewheel","keyup","touchmove"];function r(){e=!1}function i(i){if(!t)return;let n=t.getAttribute("data-offset")||1,o=t.getAttribute("data-offset-mobile")||1,d=i||t.getAttribute("data-animation-duration"),c=window.innerWidth<768?Number(o):Number(n);!function(t,i){const n=document.scrollingElement||document.documentElement,o=n.scrollTop,d=t-o,c=+new Date;e=!0,a.forEach(t=>{document.documentElement.addEventListener(t,r)}),function l(){if(!e)return;const s=+new Date-c;var u,m,p;n.scrollTop=parseInt((u=s,m=o,p=d,(u/=i/2)<1?p/2*u*u+m:-p/2*(--u*(u-2)-1)+m)),s<i?requestAnimationFrame(l):(n.scrollTop=t,e=!1,a.forEach(t=>{document.documentElement.removeEventListener(t,r)}))}()}(function(t){let e=t.getBoundingClientRect();return{top:e.top+window.scrollY,left:e.left+window.scrollX}}(t).top-c,d||700)}function n(t){return t&&"stamped-rating-badge"===t.localName&&t.hasAttribute("data-revalid
@husseyexplores
husseyexplores / yotpo-stars.html
Created August 11, 2021 13:17
[Yotpo] yotpo #yotpo
<script>
// stars placeholder: <div class="yotpo bottomLine" data-product-id="123123"></div>
(function() {
function domReady(fn) {
// If we're early to the party
document.addEventListener("DOMContentLoaded", fn);
// If late; I mean on time.
if (document.readyState === "interactive" || document.readyState === "complete" ) {
fn();
@husseyexplores
husseyexplores / back-in-stock-custom.html
Created August 11, 2021 13:12
[Klaviyo Integration] Klaviyo signup form & BIS #klaviyo
<button type="button" class="btn klaviyo-bis-trigger-custom" {% if product.selected_or_first_available_variant.available %}style="display: none;"{% endif %}>Notify me when available</button>
<div
id="KlaviyoBIS-{{ product.id }}"
class="modal modal--square modal--mobile-friendly klaviyo-bis-popup"
data-product-id="{{ product.id }}"
>
<div class="modal__inner">
<div class="modal__centered medium-up--text-center">
<div class="modal__centered-content">
@husseyexplores
husseyexplores / shopify-prevent-preview-bar.html
Created March 13, 2021 06:19
[Shopify Prevent Preview Bar] Prevents loading Shopify preview bar scripts #shopify #previewbar
<script>
let removeCount = 0;
window.mobserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
mutation.addedNodes.forEach((node) => {
var nodeName = node.nodeName
if (nodeName === 'SCRIPT') {
const script = mutation.addedNodes[0];
if(script.src.includes('/storefront/bars')) {
@husseyexplores
husseyexplores / Much much simpler option selector for Shopify
Last active October 5, 2022 19:33 — forked from zakhardage/Much much simpler option selector for Shopify
Much simpler version of Shopify's option_selection.js for separating product options into their own dropdown menus.
<form action="/cart/add" method="post" enctype="multipart/form-data" class="product-form" id="AddToCartForm">
{% unless product.has_only_default_variant %}
{% for option in product.options_with_values %}
<label {% if option.name == 'default' %}class="label--hidden" {% endif %}for="SingleOptionSelector-{{ forloop.index }}">{{ option.name }}</label>
<select id="SingleOptionSelector-{{ forloop.index }}" onchange="updateVariant();">
{% for value in option.values %}
<option value="{{ value | escape }}"{% if option.selected_value == value %} selected="selected"{% endif %}>{{ value }}</option>
{% endfor %}
</select>