Skip to content

Instantly share code, notes, and snippets.


Wes Bos wesbos

View GitHub Profile
wesbos / nuke-bot-tags.js
Created Nov 29, 2022
grease monkey script to remove bot tags
View nuke-bot-tags.js
// ==UserScript==
// @name Remove Bot Tags
// @version 1
// @grant none
// ==/UserScript==
function nukeEm() {
console.log('Nuke em!');
Array.from(document.querySelectorAll('a[href*="SaveTo"], a[href*="memdotai"]'))
.map(link => {
View non-empty-string.ts
// Here we check if our custom type "Stringy" extends a narrow type of ''
// If it does, the type is never
// If it doesnt, the type is "Strinfy", which is just a string type
function getItem<Stringy extends string>(
id: Stringy extends '' ? never : Stringy
) {
// code here
// works:
getItem('abc123'); // No error
View tik-tok-photoboot-app.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>🔥 Make a photo booth app in about 15 lines of JavaScript</title>
<link rel="icon" href="🎥" />
View fix-notion.js
function fixNotionPadding() {
Array.from(document.querySelectorAll(`[style*="padding-left: 96px"]`)).forEach(el => = 0);
View detect.ts
import { codes } from './database';
const app = document.querySelector('.app') as HTMLDivElement;
const videoEl = app.querySelector('video');
const canvasEl = app.querySelector('canvas');
const labelsEl = app.querySelector('.labels') as HTMLDivElement;
const ctx = canvasEl.getContext('2d');
interface Window {
BarcodeDetector: any;
wesbos / service-worker.js
Created Mar 24, 2022
Nuke a service worker from inside a service worker
View service-worker.js
// put this in a file where your service worker used to live, like You can find out this path in the SW dev tools of your browser
self.addEventListener('install', (e) => {
console.log('[Service Worker] Installing Service Worker ...', e);
self.addEventListener('activate', (e) => {
console.log('[ServiceWorker] Activate');
View you-cant-spell-without.ts
interface Without {
without(withoutWord: string): boolean;
// 1. Easiest / the way I'd do it
function youCantSpell(word: string): Without {
return {
without(withoutWord: string) {
return word.includes(withoutWord);
View tls.js
View what.js
function update(cache, payload) {
const [removeFromCart, { loading }] = useMutation(REMOVE_FROM_CART_MUTATION, {
variables: { id },
// When the optimistic response comes back, it seems to re-fetch every single query on the page, leaving `data` from queries undefined (and loading and error undefined as well), causing the layout to break.
// // The error itself comes from next.js, and it does seem that the item is evicted from the cache before that happens...
// optimisticResponse: {