Skip to content

Instantly share code, notes, and snippets.

View bjornpagen's full-sized avatar
🍇

Bjorn Pagen bjornpagen

🍇
View GitHub Profile
@bjornpagen
bjornpagen / img.sh
Last active February 17, 2023 07:37
A Really Terrible Image Randomizer - uses exiftool and imgmagick
#!/bin/bash
mkdir imgs
res=()
for lhs in -1 1
do
for rhs in $(seq -w 0 99)
do
res+=("${lhs}.${rhs}")
@bjornpagen
bjornpagen / deleteNotionToggleElements.js
Created January 31, 2023 20:32
A JavaScript function to delete all elements with the class notion-toggle from the DOM.
function deleteNotionToggleElements() {
const elements = document.getElementsByClassName("notion-toggle");
while (elements.length > 0) {
elements[0].parentNode.removeChild(elements[0]);
}
}
document.addEventListener("DOMContentLoaded", function() {
deleteNotionToggleElements();
});
@bjornpagen
bjornpagen / ga4-utm-parameters-event.js
Created January 31, 2023 03:20
A JavaScript code snippet for logging UTM parameters as a GA4 event, only including parameters that are set in the URL and omitting any parameters that are not set.
// Get the UTM parameters from the URL
var search = window.location.search;
var params = new URLSearchParams(search);
// Keep track of if an event has already been logged
var eventLogged = false;
// Loop through each UTM parameter
for (var [key, value] of params.entries()) {
// Check if the parameter is "utm_source", "utm_medium", "utm_campaign", "utm_term", or "utm_content"
@bjornpagen
bjornpagen / append-utm-params.js
Last active January 31, 2023 03:00
Append UTM parameters to specific domains in a webpage using JavaScript. The function loops through all the links on a page and checks if the link is part of the specified domains. If it is, the UTM parameters from the URL are added to the link.
function appendUTMParams(domains) {
// Get all the links on the page
var links = document.getElementsByTagName("a");
// Get the UTM parameters from the URL
var search = window.location.search;
var params = new URLSearchParams(search);
// Array of allowed UTM parameters
var allowedUTMs = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];