Skip to content

Instantly share code, notes, and snippets.

@kenbellows
kenbellows / removeOverlay.js
Last active February 7, 2020 04:25
JavaScript code and bookmarklet to cancel annoying "Please disable ad blocker" overlays that cover the page and disable scrolling
// find the element in the body with max z-index
// adapted from this StackOverflow answer by Jimmy Chandra:
// https://stackoverflow.com/a/1118216/470925
let max, maxVal = 0
document.querySelectorAll('body *').forEach(el => {
// get position and zIndex style values for the element
const {position, zIndex} = document.defaultView.getComputedStyle(el)
// skip statically positioned elements
if (position !== 'static') {
// parse the string value of zIndex into an integer, defaulting to 1,
@kenbellows
kenbellows / clusterPoints.js
Last active December 4, 2025 12:48
greedy agglomerative merging
/**
* Clusters 2D points so each cluster can be enclosed in a circle of radius <= d.
* Uses greedy agglomerative merging: repeatedly merge the pair of clusters whose
* merged centroid distance is smallest, as long as the merged cluster's max
* distance from its centroid <= d.
*
* @param {Array<[number, number]>} points - array of [x, y] pairs
* @param {number} d - maximum allowed radius for any cluster
* @returns {Array<Array<[number, number]>>} clusters
*/