Skip to content

Instantly share code, notes, and snippets.

<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
var params = window.location.search;
var links = document.querySelectorAll('a[href^="/"]');
links.forEach(function(link) {
link.href = link.href + params;
});
});
</script>
<video width="640" muted="" autoplay="" loop="">
<source src="https://dl.dropboxusercontent.com/s/xvr3i0tiwohjaqum2stuq/WhatsApp-Video-2024-01-25-at-11.50.47.mp4?rlkey=l6fj9qd7dum3w31ll1j755cpz" type="video/mp4">
</video>
if (document.documentElement.lang.startsWith('fr')) {
// page is French, run the script.
}
@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
@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 / smooth-scroll-css.html
Created November 11, 2023 20:55
Smooth scroll
<style>
html {
scroll-behavior: smooth;
}
</style>
@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);
});
});
<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 / 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;
@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;
}