Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 2024-07-14
// @description try to take over the world!
// @author You
// @match https://www.notion.so/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=notion.so
// @grant GM.addStyle
// ==/UserScript==
// ==UserScript==
// @name copyNyaaMagnets
// @namespace http://tampermonkey.net/
// @version 2024-07-02
// @description try to take over the world!
// @author Julen
// @match https://nyaa.si/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=nyaa.si
// @grant none
// ==/UserScript==
@julenwang
julenwang / useAsyncBlocker.ts
Created April 11, 2023 10:25
useAsyncBlocker for react-router v6.7+
import { useCallback, useRef } from 'react';
import { unstable_useBlocker as useBlocker, useBeforeUnload, useNavigate } from 'react-router-dom';
function useAsyncBlocker(isBlockFn: () => Promise<boolean>) {
const navigate = useNavigate();
const isBlockRef = useRef(true);
const blockerArgsRef = useRef<Parameters<Exclude<Parameters<typeof useBlocker>[0], boolean>>[0]>();
const willBlock = useCallback(async () => {
@julenwang
julenwang / extract-subtitles-from-mkv.md
Created April 8, 2023 14:04 — forked from pavelbinar/extract-subtitles-from-mkv.md
Extract subtitles from .mkv files on Mac OS X
// ==UserScript==
// @name copyNcRawsAllUrls.js
// @version 0.3.0
// @description 2023/06/29
// @author Julen
// @match https://ouo.si/*
// @grant none
// ==/UserScript==
(function () {
// ==UserScript==
// @name copyLilithAllUrls.js
// @version 0.1.0
// @description 2022/05/05
// @author Julen
// @match https://*.lilith001.workers.dev
// @grant none
// ==/UserScript==
(function () {
@julenwang
julenwang / salaDictCustom.css
Last active July 14, 2024 03:49
sala dict custom css
.dictPanel-FloatBox-Container.saladict-theme .dictPanel-Root {
transform: translate(0px, 70px);
}
.dictPanel-FloatBox-Container.saladict-theme .dictPanel-Head {
display: none;
}
.dictPanel-FloatBox-Container.saladict-theme .mtaBox-DrawerBtn {
display: none;
}
.dictPanel-FloatBox-Container.saladict-theme .waveformBox {
@julenwang
julenwang / ComposeSharp.ts
Last active November 1, 2022 09:23
Merge two types, overlapping part use union
type IsPartial<T> = T extends Required<T> ? false : true;
type NoPartial<Sharp1, Sharp2> = IsPartial<Sharp1> & IsPartial<Sharp2> extends true ? false : true;
// Merge two types, overlapping part use union
export type ComposeSharp<
Sharp1,
Sharp2,
InterKeys extends keyof Sharp1 & keyof Sharp2 = keyof Sharp1 & keyof Sharp2
> = UnionToIntersection<
InterKeys extends unknown
? NoPartial<Pick<Sharp1, InterKeys>, Pick<Sharp2, InterKeys>> extends true
payload:
- IP-CIDR,8.8.8.8/32
# - IP-CIDR,1.1.1.1/32
@julenwang
julenwang / useStateWithCallback.ts
Created June 2, 2022 05:56
useStateWithCallback.ts
import React, { useEffect, useRef, useState } from 'react';
export const useStateWithCallback = <T>(
initialState: T
): [state: T, setState: (updatedState: React.SetStateAction<T>, callback?: (updatedState: T) => void) => void] => {
const [state, setState] = useState<T>(initialState);
const callbackRef = useRef<(updated: T) => void>();
const handleSetState = (updatedState: React.SetStateAction<T>, callback?: (updatedState: T) => void) => {
callbackRef.current = callback;