Skip to content

Instantly share code, notes, and snippets.

View willwillems's full-sized avatar
🌱
Working remotely

Will Willems willwillems

🌱
Working remotely
View GitHub Profile
@willwillems
willwillems / sidebery.css
Created August 7, 2023 17:29
No-tab minimal Firefox layout for use with sidebar UX (Sidebery, tree style tabs, etc)
#root.root {--nav-btn-width: 36px;}
#root.root {--nav-btn-height: 32px;}
#root.root {--tabs-margin: 8px;}
#root.root {--tabs-indent: 12px;}
#root.root {--tabs-inner-gap: 8px;}
@willwillems
willwillems / script.js
Created February 12, 2023 21:51
Dark mode for Mem.ai
// ==UserScript==
// @name Mem.ai dark mode
// @namespace Violentmonkey Scripts
// @match https://mem.ai/*
// @grant none
// @version 1.0
// @author Will Willems
// @description 12/02/2023, 15:00:05
// ==/UserScript==
@willwillems
willwillems / script.js
Last active December 7, 2022 16:39
ChatGPT code execution
// ==UserScript==
// @name New script openai.com
// @namespace Violentmonkey Scripts
// @match https://chat.openai.com/chat
// @grant none
// @version 1.1
// @author -
// @description 04/12/2022, 13:07:34
// ==/UserScript==
@willwillems
willwillems / README.md
Last active March 23, 2022 14:31
VS Code Regex find and replace require syntax with import syntax

Simple require imports, for example const bar = require("foo"):

  • Regex: (const|var|let)\b\s+(\w+)\s+=\s+require\s*\(["']([\/\w\-]+)["']\)\n
  • Replace: import $2 from "$3"\n

One-liner require & config/compute, for example const router = require("express").Router({ mergeParams: true }):

  • Regex: (const|var|let)\b\s+(\w+)\s+=\s+require\s*\(["'](\w+)["']\)(?=\S+)
@willwillems
willwillems / deploy-functions.yml
Created February 9, 2021 12:05
Deploy Firebase functions with Github Actions
name: Build and Deploy
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
@willwillems
willwillems / getMatchingCSSRulesForEl.js
Created January 10, 2021 13:55
Get matching CSS rules for a DOM element using the new CSSOM stylesheet implementation
function getMatchingCSSRulesForEl (el) {
return [...document.styleSheets]
.filter(ss => { try { return ss.cssRules; } catch (e) { return false } })
.flatMap(e => [...e.cssRules].filter(r => el.matches(r.selectorText)))
}
@willwillems
willwillems / AppStartRating.vue
Created November 22, 2020 14:11
Vue Component for 5 star rating
<template>
<div class="product-rating" :class="{'product-rating--invalid': ratingIsNan}">
<div class="product-rating__value-cutoff" :style="`width: ${cutoffWidth}%;`">
<img class="product-rating__star" :class="{'product-rating__star--small': isSmall}" src="/icon/star.svg" />
<img class="product-rating__star" :class="{'product-rating__star--small': isSmall}" src="/icon/star.svg" />
<img class="product-rating__star" :class="{'product-rating__star--small': isSmall}" src="/icon/star.svg" />
<img class="product-rating__star" :class="{'product-rating__star--small': isSmall}" src="/icon/star.svg" />
<img class="product-rating__star" :class="{'product-rating__star--small': isSmall}" src="/icon/star.svg" />
</div>
</div>
@willwillems
willwillems / fullscreen-activate.js
Last active May 3, 2020 10:33
Put Roam Research in fullscreen by clicking anywhere.
((b) => { b.style.backgroundColor = 'white'; b.addEventListener('click', () => b.requestFullscreen(), {once: true})})(document.body)
@willwillems
willwillems / indent.js
Last active April 12, 2020 11:12
Indent browser CSS with a simple JS function
const indent = code => code
.replace(/{\s+/, '{\n ')
.replace(/(?<=;)\s+/gm, '\n ')
.replace(/(?<=;)\s+}/, '\n} ')
@willwillems
willwillems / background.js
Last active December 4, 2020 10:01
Custom webpack chunk loading from a web extension (Chrome) content script.
// Throw this in your background script, it injects a generated webpack chunk when asked
chrome.runtime.onMessage.addListener(function ({ type, data}, sender, sendResponse) {
if (type === 'requestFileInjection') {
const file = data.fileName
if (!file) throw new Error('No file name provided.')
chrome.tabs.executeScript({ file: `${file}.js` }, (result) => {
console.log(`${file}.js injected`)
return sendResponse({ type: 'injected', target: { src: `${file}.js` }, success: true })
})
return true // return true so sendResponse stays valid