Skip to content

Instantly share code, notes, and snippets.

View NightScript370's full-sized avatar
💭
I may be slow to respond.

NightScript NightScript370

💭
I may be slow to respond.
View GitHub Profile
@NightScript370
NightScript370 / toPx.ts
Last active August 24, 2022 02:57 — forked from wKich/toPx.js
convert CSS units to pixels
// imported from https://github.com/heygrady/Units
let preCalculated = false;
let computedValueBug = false;
const defaultView = document.defaultView;
const getComputedStyle = defaultView && defaultView.getComputedStyle;
const runit = /^(-?[\d+\.\-]+)([a-z]+|%)$/i;
const convert:Record<string, number|undefined> = {
mm2px: 1/25.4,
@NightScript370
NightScript370 / lightshot-image-extractor.ts
Last active December 26, 2021 15:30 — forked from foyez/lightshot-image-extractor.js
LightShot Image Extractor: scrapes the jpg screenshot link from a LightShot page
import { DOMParser, Element, HTMLDocument } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
/**
* Extracts the jpg url from a LightShot page
* lightshot_image('http://prntscr.com/dki21q')
* http://image.prntscr.com/image/1aaf571d0adf4aa098eb565bbb196af6.png
*/
export default async function lightshotImageExtractor(url:URL):URL {
const connection = await fetch(url.href);
if (!connection.ok) throw Error("Connection not OK");