테스트 환경
| const getUrl = (elem: Element) => elem.getAttribute("href")!.split("?")[0] | |
| const setQuery = (selector: string, query: string) => () => { | |
| const elem = document.querySelector(selector) | |
| if (!elem) { | |
| console.log(`elem with ${selector} not found`) | |
| return | |
| } | |
| const newSearchParams = new URLSearchParams({ q: query }) | |
| elem.setAttribute("href", `${getUrl(elem)}?${newSearchParams}`) |
테스트 환경
| #!/usr/bin/env -S deno run --allow-read --allow-write --allow-run --allow-env --unstable | |
| import { Command } from "https://deno.land/x/[email protected]/command/mod.ts" | |
| import { dirname, join } from "https://deno.land/[email protected]/path/mod.ts" | |
| import { c, p } from "https://deno.land/x/[email protected]/mod.ts" | |
| const mapKeys = | |
| <A>(f: (k: string) => string) => (record: Readonly<Record<string, A>>): Record<string, A> => | |
| Object.fromEntries(Object.entries(record).map(([k, v]) => [f(k), v])) |
| import { | |
| bgBrightRed, | |
| bold, | |
| brightGreen, | |
| brightRed, | |
| brightWhite, | |
| brightYellow, | |
| } from "https://deno.land/[email protected]/fmt/colors.ts" | |
| import { c, p } from "https://deno.land/x/[email protected]/mod.ts" | |
| import { match } from "npm:ts-pattern" |
| declare global { | |
| interface PromiseConstructor { | |
| resolve<const T>(value: T): Promise<Awaited<T>> | |
| } | |
| } |
Deno는 Node.js를 만든 Ryan Dhal의 차세대 자바스크립트/타입스크립트 런타임입니다.
| import { z } from "https://deno.land/x/[email protected]/mod.ts" | |
| import { HasType } from "./type_helper.ts" | |
| export type AnyZodEffect = z.ZodEffects<z.ZodTypeAny, unknown, unknown> | |
| export type ObjectSchema = z.ZodObject<z.ZodRawShape> | |
| /** Recursively checks if schema has a transform effect for either the whole object or a property. */ | |
| export type HasZodEffect<T> = T extends ObjectSchema | |
| ? HasType<T["shape"], AnyZodEffect> extends true ? true |
| import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts" | |
| /** @example | |
| * const input = [1, 1, -1, 1, -1, 1] | |
| * assertEquals(span(input, (x) => x > 0), [[1, 1], [-1, 1, -1, 1]]) | |
| */ | |
| export const span = <T>(array: T[], predicate: (line: T) => boolean): [T[], T[]] => { | |
| const index = array.findIndex((line) => !predicate(line)) | |
| const before = index === -1 ? array : array.slice(0, index) | |
| const after = index === -1 ? [] : array.slice(index) |
| import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts" | |
| import { outdent } from "npm:outdent" | |
| import { trisection } from "./partition_utils.ts" | |
| import { walk } from "https://deno.land/[email protected]/fs/walk.ts" | |
| import { asynciter } from "https://deno.land/x/[email protected]/asynciter.ts" | |
| import { fromFileUrl, join, resolve } from "https://deno.land/[email protected]/path/mod.ts" | |
| export const SCRIPT_DIR = fromFileUrl(import.meta.url) | |
| export const TOP_DIR = resolve(SCRIPT_DIR, "..", "..", "..") | |
| export const JSON_DIR = join(TOP_DIR, "data") |
| // ==UserScript== | |
| // @name Github local timezone format | |
| // @namespace https://github.com/scarf005 | |
| // @match https://github.com/* | |
| // @match https://gist.github.com/* | |
| // @version 1.1.0 | |
| // @description Make github use local timezone format | |
| // @icon https://github.githubassets.com/pinned-octocat.svg | |
| // @grant none | |
| // @downloadURL https://gist.githubusercontent.com/scarf005/20a54f241aabebe89ff3d375b1fc59ff/raw/github-local-timezone.user.js |