Skip to content

Instantly share code, notes, and snippets.

View ginader's full-sized avatar

Dirk Ginader ginader

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Audio archive</title>
<style>
body {
font-family: helvetica,arial,sans-serif;
color: #333;
@rodneyrehm
rodneyrehm / manual-overflow-scroll.js
Created January 10, 2017 20:41
Android 4.4 / Chrome 30 WebView: Manual Scrolling of overflow elements
// see https://bugs.chromium.org/p/chromium/issues/detail?id=294514 for an explanation of the problem, with a very helpful automatic archival
// If you use this "code" you're going to burn in a very special level of hell.
// A level they reserve for child molesters and people who talk at the theater.
function engageManualScrolling(element) {
var start = 0;
var handleStart = function(event) {
start = element.scrollTop + event.touches[0].pageY;
};
@jwilson8767
jwilson8767 / es6-element-ready.js
Last active February 24, 2025 08:50
Wait for an element to exist. ES6, Promise, MutationObserver
// MIT Licensed
// Author: jwilson8767
/**
* Waits for an element satisfying selector to exist, then resolves promise with the element.
* Useful for resolving race conditions.
*
* @param selector
* @returns {Promise}
*/
@tomhodgins
tomhodgins / container-queries-stylesheet-edition.es5.js
Last active April 10, 2018 06:29
Container Queries Mixin: Stylesheet version (using $this as a keyword for matching tags)
function containerQuery(selector, test, stylesheet) {
var tag = document.querySelectorAll(selector)
var style = ''
var count = 0
for (var i=0; i<tag.length; i++) {
var attr = (selector+test).replace(/\W+/g, '')
@asontu
asontu / mop.js
Last active June 28, 2021 11:36
Functions to easily make a MutationObserver Promise in JavaScript. Usage described on my blog: https://asontu.github.io/2020/12/30/mutationobserver-promise-made-easy.html
/**
* Runs "trigger" function after setting up MutationObserver and (optionally) Timeout
* that respectively resolve or reject the Promise. The resolve function gets an array
* (not NodeList) of elements that were added as argument. If the trigger function
* returns true the Promise is immediately resolved with an empty array, without waiting
* for a Mutation.
*
* @param {Function} trigger Function to run after setting up MutationObserver and Timeout.
* @param {Object} watch DOM Element to watch for Mutations.
* @param {string} [query=*] Selector query that elements added in the Observed Mutation must match.
@Haprog
Haprog / deepQuerySelectorAll.js
Created May 5, 2021 08:36
A version of querySelectorAll() that also recursively looks into all shadow roots
/**
* A version of querySelectorAll() that also recursively looks into all shadow roots.
* @param selector Selector
* @param root (Optional) Scope of the query (Element or Document). Defaults to the document.
* @returns
*/
function deepQuerySelectorAll(selector, root) {
root = root || document;
const results = Array.from(root.querySelectorAll(selector));
const pushNestedResults = function (root) {