Skip to content

Instantly share code, notes, and snippets.

View Strongground's full-sized avatar

Noël Ströhmer-Lohfink Strongground

View GitHub Profile
@Strongground
Strongground / gist:72b5d053f5b61bc2e0ea141d24aef985
Created May 23, 2024 14:29
Remove non-free "premium" entries from free3d.com's search results
document.querySelectorAll('.search-results .optimize-mixed div.search-result').forEach(item => {if (item.className.indexOf('premium') > -1) {item.remove()}})
@Strongground
Strongground / scanblue-abtest-snippet.js
Last active May 5, 2023 07:38
ScanBlue A/B Test Snippet, adding inline all necessary code to display two buttons according to CC-16566
const version = '1.1.2';
/**
* Returns the HTML for the modal, which is used for both AR and 3D.
* @param {String} id The ID of the type of modal, can only be "ar" or "3d". Is used for class names and data attributes.
* @returns {String} The HTML for the modal
*/
function getModal(id) {
return `<div class="modal fade modal-scanblue modal-scanblue-${id}" data-scanblue-type="${id}" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content modal-bg-white">
@Strongground
Strongground / emit.lib.js
Last active April 9, 2024 13:51
emit() function for custom events
/**
* Based on Chris Ferdinandis emit() function as shown in his great newsletter.
* See also https://gomakethings.com/a-vanilla-js-custom-event-helper-function/
* Emit a custom event
* @param {String} type The event type
* @param {any} detail Any details to pass along with the event
* @param {Node} elem The element to emit the event on
*/
function emit (type, detail, elem = document) {
@Strongground
Strongground / defer.js
Last active August 12, 2020 08:12
Defer method to deferred loading of any method requiring jQuery on root level of webpages
function defer(method) {
if (window.jQuery) {
method()
} else {
setTimeout(function() { defer(method) }, 50)
}
}
@Strongground
Strongground / debugging.htm
Created January 15, 2019 14:08
Universal Debugging Styles
<style>
.debug {
position:fixed;
bottom:0;
left:0;
z-index:99999999;
width:100%;
min-height:25px;
line-height:25px;
background:#ef4f2f;
@Strongground
Strongground / recommendation_mutation_observer.js
Created January 8, 2019 18:29
SFCC: Mutation Observer for Recommendation slots
/**
* Setup Mutation Observers for Recommendations Slots
* When recommendations markup is loaded, fire off Mutation Observer callback
* - Init Product Tile Carousel on Recommendation Product Tiles
*/
function initRecommendations() {
var observer = new MutationObserver(function(mutations, observer) {
var $this = $(mutations[0].target);
// This is the logic to ensure that initProductTileCarousel()