Skip to content

Instantly share code, notes, and snippets.

View memetican's full-sized avatar

Michael Wells memetican

View GitHub Profile
@memetican
memetican / cms-load.html
Created September 10, 2023 23:03
fs-cms-load
<script>
window.fsAttributes = window.fsAttributes || [];
window.fsAttributes.push([
'cmsload',
(listInstances) => {
console.log('cmsload Successfully loaded!');
// The callback passes a `listInstances` array with all the `CMSList` instances on the page.
const [listInstance] = listInstances;
@memetican
memetican / close-dropdown.html
Last active September 17, 2023 00:24
Webflow Fixes
<script>
$("a[href^='#']").click(function() {
$(this).closest("nav").removeClass("w--open");
$(this).closest("div.w-dropdown-toggle").removeClass("w--open");
});
</script>
@memetican
memetican / lowered-captions.html
Last active September 25, 2023 22:14
Webflow Lightbox
<style>
.w-lightbox-group .w-lightbox-image {
max-height: calc(84vh - 50px);
}
.w-lightbox-caption {
bottom: -50px;
}
.w-lightbox-figure {
top: -25px;
}
@memetican
memetican / auto-login.html
Created September 26, 2023 18:53
Webflow Auto-Login Hack
<script>
document.addEventListener('DOMContentLoaded', function() {
// Function to get a query string value by name
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
<script>
window.fsAttributes = window.fsAttributes || [];
// Apply the initial input counter value as filter state
window.fsAttributes.push([
'cmsfilter',
(filterInstances) => {
console.log('cmsfilter Successfully loaded!');
const counterButtons = document.querySelectorAll('.fs_inputcounter-1_button');
@memetican
memetican / shopify-tabs-fix.html
Created October 3, 2023 21:02
Shopify + Webflow
<script>
document.addEventListener('DOMContentLoaded', (event) => {
const tabs = document.querySelectorAll('[data-w-tab]');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
setTimeout(() => {
window.dispatchEvent(new Event('resize'));
}, 200);
});
});
@memetican
memetican / smooth-scroll-css.html
Created November 11, 2023 20:55
Smooth scroll
<style>
html {
scroll-behavior: smooth;
}
</style>
@memetican
memetican / base64-example.css
Last active December 16, 2023 05:37
Locale Switcher
.locale-item[lang-iso-code=zh] .locale-flag {
background-image: url("data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgaWQ9ImZsYWctaWNvbnMtY24iIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj4KICA8ZGVmcz4KICAgIDxwYXRoIGlkPSJjbi1hIiBmaWxsPSIjZmYwIiBkPSJNMS0uMy0uNy44IDAtMSAuNi44LTEtLjN6Ii8+CiAgPC9kZWZzPgogIDxwYXRoIGZpbGw9IiNlZTFjMjUiIGQ9Ik0wIDBoNTEydjUxMkgweiIvPgogIDx1c2UgeGxpbms6aHJlZj0iI2NuLWEiIHdpZHRoPSIzMCIgaGVpZ2h0PSIyMCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTI4IDEyOClzY2FsZSg3Ni44KSIvPgogIDx1c2UgeGxpbms6aHJlZj0iI2NuLWEiIHdpZHRoPSIzMCIgaGVpZ2h0PSIyMCIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMSAxNDIuNiAtNDcpc2NhbGUoMjUuNTgyNykiLz4KICA8dXNlIHhsaW5rOmhyZWY9IiNjbi1hIiB3aWR0aD0iMzAiIGhlaWdodD0iMjAiIHRyYW5zZm9ybT0icm90YXRlKC05OC4xIDE5OCAtODIpc2NhbGUoMjUuNikiLz4KICA8dXNlIHhsaW5rOmhyZWY9IiNjbi1hIiB3aWR0aD0iMzAiIGhlaWdodD0iMjAiIHRyYW5zZm9ybT0icm90YXRlKC03NCAyNzIuNCAtMTE0KXNjYWxlKDI1LjYxMzcpIi8+CiAgPHVzZSB4bGluazpocmVmPSIjY24tYSIgd2lkdGg9IjMwIiBoZWlnaHQ9IjIwIiB0cmF
@memetican
memetican / localize-dates.js
Created December 22, 2023 17:58
Webflow Localization
// Get the date from your source field
// Identify by class, ID, or a custom attriute
// HACK: We'll use today's date as a placeholder
const date = new Date();
// Get the current locale (e.g., 'it-IT' for Italian, 'en-US' for American English)
const locale = document.documentElement.lang;
// If none, exit, we don't want to change the date
// or, you can get the browser's locale as a backup
if (document.documentElement.lang.startsWith('fr')) {
// page is French, run the script.
}