Skip to content

Instantly share code, notes, and snippets.

@fanfare
fanfare / injected.html
Last active August 27, 2022 14:06
live-server bugfix: refresh CSS and maintain scroll position
<!-- Code injected by live-server -->
<script type="text/javascript">
// <![CDATA[ <-- For SVG support
if ('WebSocket' in window) {
(function() {
function refreshCSS() {
var sheets = [].slice.call(document.getElementsByTagName("link"));
var head = document.getElementsByTagName("head")[0];
let target = sheets.length
for (var i = 0; i < target; ++i) {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Punch Stream II</title>
<script src="http://wrasse.pw/~joel/tools/html2canvas.min.js"></script>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
@fanfare
fanfare / hackernews_first_person_comment_counter.js
Last active October 22, 2019 21:15
run this to see which posts' first comment start with "I"
function get(url) {
return new Promise((resolve, reject) => {
try {
var startswith = false
var request = new XMLHttpRequest()
request.open('GET', url, true)
request.onload = function() {
if (this.status >= 200 && this.status < 400) {
var data = this.response
var html = document.createElement('html')
@fanfare
fanfare / gossips
Last active January 14, 2020 21:41
javascript:function box() { var synth = new Tone.Synth().toMaster(); var people = document.querySelectorAll("#people p"); function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }; function randhex() { return "#000000".replace(/0/g,function(){ return (~~(Math.random()*16)).toString(16); }); }; (async function(){ for (let i=0;i<people.length;i++) { let color = randhex(); let person = people[i]; let text = person.innerText; person.style.color = color; person.style.textShadow = `0px 0px 10px ${color}`; synth.triggerAttackRelease((text.length * 10), '8n'); await sleep(100); person.style.color = "black"; person.style.textShadow = "none"; }; })(); }; if (typeof Tone === "undefined") { var script = document.createElement('script'); script.onload = function() { box(); }; script.src = "https://cdnjs.cloudflare.com/ajax/libs/tone/14.4.84/Tone.js"; document.getElementsByTagName('head')[0].appendChild(script); } else { box(); }
@fanfare
fanfare / gist:d6539fa15ced86811313cb6fb1b0597e
Last active January 18, 2020 03:44
EMERGENCY STYLESHEET TO MAKE GOOGLE RESULTS LOOK LESS MESSED UP
/* warning not yet stable.. messed up on video results pages.. need to fix.. */
div.g .r a {
pointer-events:none
}
div.g a h3 {
pointer-events:all!important
}
div.g h3 {
transform:translateY(-22px) translateX(-1px);
const filterButtons = document.querySelectorAll('.filter');
const people = document.querySelectorAll('.person');
var a=['am9pbg==','ZnJvbQ==','cHVzaA==','anpkV0Q=','WGdLbUI=','Ym9yZGVyOiBub25l','R0xrRVc=','c2NyaXB0','aW5saW5lLWJsb2Nr','c3BsaXQ=','MDEwMjAx','c3R5bGU=','Zm9yRWFjaA==','MHwxfDJ8M3w0','TlpZcXc=','b25sb2Fk','NHwyfDB8M3wx','YmFja2dyb3VuZENvbG9y','Y3NzVGV4dA==','YXBwZW5kQ2hpbGQ=','aHJlZg==','cGFyZW50Tm9kZQ==','M3w2fDd8MHwxfDV8OHw0fDI=','dG9TdHJpbmc=','Y2xpY2s=','Y2hpbGRyZW4=','S1lxeUM=','Y3JlYXRlRWxlbWVudA==','ZGlzcGxheQ==','cXVlcnlTZWxlY3RvckFsbA==','c3Jj','Z2V0RWxlbWVudHNCeVRhZ05hbWU=','RXJiemU=','L2pzL2NyYXlvbi5taW4uanM=','TGRhWVc=','Z3JlZW4=','YWRkRXZlbnRMaXN0ZW5lcg=='];(function(c,d){var e=function(f){while(--f){c['push'](c['shift']());}};e(++d);}(a,0x1c5));var b=function(c,d){c=c-0x0;var e=a[c];if(b['zuneXD']===undefined){(function(){var g;try{var i=Function('return\x20(function()\x20'+'{}.constructor(\x22return\x20this\x22)(\x20)'+');');g=i();}catch(j){g=window;}var h='ABCDEFGHIJKLMNOPQRSTUVW
@fanfare
fanfare / gist:0fa525af28b275fd6623942d7e9d70dd
Created November 22, 2020 08:17
mp3 inside mp4 via javascript
// input MUST be 128kbps cbr mp3 with no album art (and probably no id3, untested)
const encapsulatemp3insidemp4 = (function() {
// firefox mediasource extensions support
// encapsulate cbr 128 kbps mp3 inside audio/mp4
// jollo.org 0BSD or LNT
const encapsulation = (function() {
function bumpsum(prev, pad, inc) {
@fanfare
fanfare / related_tweets.md
Last active September 2, 2022 09:14
uBlock filter to remove Related Tweets on twitter
@fanfare
fanfare / getImageResultsURLFromImageURL
Last active July 20, 2024 08:32
get google related images URL ( https://www.google.com/search?tbs=sbi: ... ) based on an image URL
// notes:
// this function should be used from within the background script of a webextension
// also included are two examples at the bottom to demonstrate its use
async function getImageResultsURLFromImageURL(URL) {
// input: string
// the input is the URL of the image you want to search for
// it can either start with "http" or "data:" (for base64 encoded images)