Skip to content

Instantly share code, notes, and snippets.

View molotow11's full-sized avatar

Andrey Myasoedov molotow11

View GitHub Profile
@molotow11
molotow11 / usf.js
Last active January 1, 2021 20:10
usf.js file modification for add banners
<template v-if="view === 'grid'">
<template v-for="(p, key) in result.items">
<!-- added for collections banner -->
<div :class="\'grid__item collection-banner\'" v-if="window.banner1_position == key" v-html="window.banner1_layout"></div>
<!-- banner 2 -->
<div :class="\'grid__item collection-banner\'" v-if="window.banner2_position == key" v-html="window.banner2_layout"></div>
<!-- /// -->
<usf-sr-griditem :product="p" :result="result"></usf-sr-griditem>
</template>
</template>
@molotow11
molotow11 / .js
Created February 2, 2021 06:22
Wait for some script loading
let wait = 0;
var waitForLoad = setInterval(function() {
// wait for $container
if($container.length || wait > 1000){
clearInterval(waitForLoad);
}
wait += 50;
}, 50);
@molotow11
molotow11 / .js
Created February 15, 2021 10:37
Defer scripts loading
var scriptsLoadDelay = 10000;
var delayedScripts = [
"https://w.sharethis.com/button/buttons.js",
];
setTimeout(function() {
console.log("Delayed scripts loading");
for(var i=0; i<delayedScripts.length; i++) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
@molotow11
molotow11 / files-download_console.js
Last active May 20, 2023 06:08
Shopif admin download settings/files images
/**
* Script for put into console for download all images from Shopify /admin/settings/files?limit=250
* This will download new file with all images inside it
* Then you need to open this file and go to browser's parameters -> Save page -> Select an option for download full page
* Then the browser will download this page and create a folder with all images inside
*/
function fetchPageAssets() {
let images = document.querySelectorAll('img[src*=files]:not(img[src*=avatar])');
images.forEach(function(image) {
@molotow11
molotow11 / gist:4814c349f24ac616c77559dbcc3b9d74
Created June 8, 2021 05:35
Load script and wait for ready
YoutubeDefer.loadAPIVideo(block) {
if(typeof YT === 'undefined') {
loadYoutubeScript();
checkIfYoutubeIsReady().then(function() {
let player = new Vimeo.Player(iframe);
player.play();
});
}
else {
let player = new Vimeo.Player(iframe);