Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name 592
// @version 0.1
// @match https://rent.591.com.tw/*
// ==/UserScript==
(function () {
'use strict';
// Check if the current URL is in the array
@ajhsu
ajhsu / script.js
Created November 26, 2020 08:41
Promise MITM monitor
// Hijack the "Promise" in browsing context.
function Promise() {}
// The list to keep Promises.
window.__promiseObservingList = [];
// Establish the customized Promise implementation
// Source: https://github.com/taylorhakes/promise-polyfill/blob/master/dist/polyfill.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
// ==UserScript==
// @name 592
// @version 0.0.1
// @author AJ Hsu <[email protected]>
// @match https://rent.591.com.tw/rent-detail-*
// @grant GM_addStyle
// ==/UserScript==
window.addEventListener('load', function handleLoaded() {
window.removeEventListener('load', handleLoaded);
// ==UserScript==
// @name Wikipedia TLDR
// @version 0.0.4
// @author AJ Hsu <[email protected]>
// @match https://*.wikipedia.org/*
// @grant GM_addStyle
// ==/UserScript==
window.addEventListener('load', function handlePageLoaded() {
window.removeEventListener('load', handlePageLoaded);
// ==UserScript==
// @name MDN Redirection
// @version 0.0.1
// @author AJ Hsu <[email protected]>
// @match https://developer.mozilla.org/zh-*
// @grant none
// ==/UserScript==
(function() {
window.location.href = window.location.pathname
// ==UserScript==
// @name Wikipedia Redirection
// @version 0.0.1
// @author AJ Hsu <[email protected]>
// @match https://zh.wikipedia.org/wiki/*
// @grant none
// ==/UserScript==
window.addEventListener('load', function handleLoaded() {
window.removeEventListener('load', handleLoaded);
@ajhsu
ajhsu / index.md
Created December 5, 2018 07:21
Bundled file size comparison when you only need debounce and throttle from Lodash.

Metrics

Without lodash
-rw-r--r--  1 ajhsu  staff    96K 12  5 14:41 app.bundle.js

Bundled with independent lodash.debounce && lodash.throttle package
-rw-r--r--  1 ajhsu  staff   106K 12  5 14:58 app.bundle.js

Bundled with `import lodash from 'lodash/function'`
@ajhsu
ajhsu / keybindings.json
Created November 7, 2018 02:45
Shortcut to insert `console.log();` in VSCode
[
{
"key": "cmd+'",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "console.log(${TM_SELECTED_TEXT}$1)$0;"
}
}
]
@ajhsu
ajhsu / .tmux.conf
Created November 3, 2018 06:22 — forked from jikkujose/.tmux.conf
Change prefix key in tmux to back-tick and still type back-ticks
unbind C-b
set-option -g prefix `
bind ` send-prefix
@ajhsu
ajhsu / inject-inline-styles.js
Last active October 26, 2018 03:45
Dynamically injects an inline stylesheet into a web page
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `
body {
background-color: yellow;
}
`;
document.querySelector('head').appendChild(style);