Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name pinia: clean document
// @namespace https://pinia.vuejs.org/
// @match https://pinia.vuejs.org/*
// @grant none
// @version 1.0
// @author -
// @description Remove unreadable web fonts style
// @run-at document-end
// ==/UserScript==
@azu
azu / README.md
Last active November 2, 2022 08:00
サブドメインをユーザーホスティングサイトに使うときのパターン(Same Origin/Cookie/Public Suffix List)

サブドメインをユーザーホスティングサイトに使うときのパターン

hoge.example.com でユーザが作成したサイトをホスティングして、任意のJavaScriptを実行できる状態にしたいケース。 サブドメインを分けることで、Fetch APIなどはSame Origin Policyを基本にするため、別のサブドメインや example.com に対するリクエストなどはできなくなる。

一方で、CookieはSame Origin Policyではない。 デフォルトでは、hoge.example.com から example.com に対するCookieが設定できる。 これを利用したDoS(Cookie Bomb)やこの挙動を組み合わせた別の脆弱性に利用できる場合がある。

@azu
azu / github-proxy-client.js
Created March 13, 2022 13:02 — forked from DavidWells/github-proxy-client.js
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
@azu
azu / irdor-komesan.user.js
Last active January 24, 2022 14:53
Greamonkey Script: irodr integrate with komesan
// ==UserScript==
// @name irodr: komesan
// @namespace github.com/azu
// @match https://irodr.netlify.app/
// @grant none
// @version 1.0
// @author azu
// @description irodr integrate
// @run-at document-end
// ==/UserScript==
@azu
azu / commonjs-module.js
Last active January 12, 2022 11:30
webpack 5.66.0 add library type: commonjs-static
"use strict";
var __webpack_require__ = {
d: (_, e) => {
for (var r in e) __webpack_require__.o(e, r) && !__webpack_require__.o(_, r) && Object.defineProperty(_, r, {
enumerable: !0,
get: e[r]
})
}, o: (_, e) => Object.prototype.hasOwnProperty.call(_, e), r: _ => {
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(_, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(_, "__esModule", { value: !0 })
}
@azu
azu / useHistoryState.ts
Created September 29, 2021 06:52
Undo/Redo Manage implementation using React Hooks: https://twitter.com/azu_re/status/1443105296994340867
type HistoryState = unknown; /* state object */
const useHistoryState = (defaultState: HistoryState) => {
const STACK_SIZE_LIMIT = 20;
const [currentState, setCurrentState] = useState<HistoryState>(defaultState);
const [undoStack, setUndoStack] = useState<HistoryState[]>([]);
const [redoStack, setRedoStack] = useState<HistoryState[]>([]);
const canUndo = useMemo(() => undoStack.length > 0, [undoStack.length]);
const canRedo = useMemo(() => redoStack.length > 0, [redoStack.length]);
const pushState = useCallback((item: HistoryState) => {
setCurrentState(item);
@azu
azu / 0.memory-note.md
Last active September 27, 2021 21:39
Memory Noteの開発メモ

目的

  • いつでも入力
  • いつでも見れる
  • とにかく早い、ストレスフリー
  • 30分とか枠を用意してそこにメモを書くのが良さそう

なぜ

  • 人の脳の容量はでかいが、記憶のスタックが小さい(疑似)
@azu
azu / furusato-tax.jp: price * 0.2.user.js
Last active August 8, 2021 04:13
furusato-tax.jpの表示金額に2割の表示を追加するGreasemonkeyスクリプト
// ==UserScript==
// @name furusato-tax.jp: price * 0.2
// @namespace furusato-tax.jpの表示金額に2割の表示を追加する
// @match https://www.furusato-tax.jp/*
// @grant none
// @version 1.0
// @author -
// @description 2021/8/8 12:08:48
// @run-at document-end
// ==/UserScript==
@azu
azu / get-domain.js
Last active June 24, 2021 03:09
Get domain(site) from url using document.cookie hacking. without public suffix
const isSite = (domain) => {
console.log(domain)
const key = "WILL_BE_FIRED." + 'xxxx-xxxx-xxx-xxxx'.replace(/[x]/g, (c) => {
const r = Math.floor(Math.random() * 16);
return r.toString(16);
});
document.cookie = `${key}=1; domain=${domain}; samesite`;
// Test wrinting
console.log("document.cookie", document.cookie)
const canWrite = document.cookie.includes(`${key}=1`);