Skip to content

Instantly share code, notes, and snippets.

@panzi
panzi / enable_context_menu.js
Created Jul 22, 2020
Bookmarklet to re-enable context menus on sites that disable it.
View enable_context_menu.js
javascript:(function(pd){Event.prototype.preventDefault=function(){if(this.type!=='contextmenu')return%20pd.apply(this,arguments);};})(Event.prototype.preventDefault);void(0)
View YouTubeThumbs.js
(function() {
"use strict";
function padd(x) {
var x = String(x);
return x.length < 2 ? '0' + x : x;
}
var duration = +document.querySelector("video").duration;
var playerData = document.querySelector("ytd-watch-flexy").__data.playerData;
@panzi
panzi / mkgif.sh
Created Oct 2, 2019
convert a video into a GIF with optimal palette
View mkgif.sh
#!/usr/bin/bash
input=/dev/stdin
output=/dev/stdout
slice=
palette="/tmp/mkgif-$$-palette.png"
fps=15
width=
crop=
@panzi
panzi / no_blocking_overlay.js
Created Apr 9, 2019
A bookmarklet that removes these nasty overlays from websites that would work perfectly fine without a login, but still want you to create one.
View no_blocking_overlay.js
javascript:Array.forEach(document.body.querySelectorAll("*"), e => { var s = getComputedStyle(e); if (s.position !== 'static' && s.position !== 'relative') { var r = e.getBoundingClientRect(); if (r.x <= 0 && r.y <= 0 && r.width >= window.innerWidth && r.height >= window.innerHeight) { e.remove(); } } }); document.body.style.overflow="auto";void(0)
@panzi
panzi / show_hide_passwords.js
Created Jan 19, 2019
Bookmarklets to make passwords in password fields readable and to hide them again.
View show_hide_passwords.js
// Show Passwords:
javascript:document.querySelectorAll('input[type=password]').forEach(e=>{e.type='text';e.setAttribute('data-io-github-panzi-password','true');});void(0)
// Hide Passwords again:
javascript:document.querySelectorAll('input[data-io-github-panzi-password=true]').forEach(e=>e.type='password');void(0)
@panzi
panzi / git-kmerge3.sh
Last active Nov 20, 2018
Merge files useing kdiff3. Using git mergetool merges files one by one, this opens all files in kdiff3 at once. TODO: somehow git add merged files after kdiff3 exists
View git-kmerge3.sh
#!/bin/bash
set -e
SUBDIRECTORY_OK=1
. "`git --exec-path`/git-sh-setup"
cd_to_toplevel
O=".git-kmerge3-tmp-$$"
list=$O/.git-kmerge3-list
@panzi
panzi / mysql_cvs_dump.py
Last active Oct 24, 2018
Dumps whole MySQL database as CSV files.
View mysql_cvs_dump.py
#!/usr/bin/env python3
import mysql.connector
import argparse
import csv
import re
import sys
from contextlib import closing
from os import makedirs
from os.path import join as join_path
View gettext.py
#!/usr/bin/env python3
import re
LEX = re.compile(
r'([_a-zA-Z]+[_a-zA-Z0-9]*)|' + # identifier
r'("(?:[^"\n\\]|\\["rnbvte\\0]|\\x[0-9a-fA-F]{2})*")|' + # string
r"('(?:[^'\n\\]|\\['rnbvte\\0]|\\x[0-9a-fA-F]{2})*')|" + # char (yes they can be more than on character in C)
r'(/\*(?:[^*]|\*[^/])*\*/)|' + # multiline comment
r'(//[^\n]*)|' + # single line comment
@panzi
panzi / Results.txt
Last active Aug 3, 2018
Find maximum regular expression length. Note that I guess the maximum length could be different if other regular expression features are used.
View Results.txt
Google Chrome 68.0.3440.84 64 bit Linux: 41943040
NodeJS v8.11.1 64 bit Linux: 41943040
Mozilla Firefox 61.0.1 64 bit Linux: 268435455
@panzi
panzi / invertColors.js
Last active Jun 26, 2018
Bookmarklet to invert colors on a page, but *not* of images and videos. Basically a quick dark-mode hack.
View invertColors.js
javascript:(function() {
function parseColor(str) {
var match = /^\s*(?:(?:#(?:([0-9a-f])([0-9a-f])([0-9a-f])|([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})))|rgb\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)|rgba\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+(?:\.[0-9]*)?|\.[0-9]+)\s*\))\s*$/i.exec(str);
if (!match) throw new SyntaxError(str);
if (match[1]) {
return {
r: parseInt(match[1], 16) * 17,
g: parseInt(match[2], 16) * 17,
b: parseInt(match[3], 16) * 17,
a: 1.0
You can’t perform that action at this time.