Skip to content

Instantly share code, notes, and snippets.

View schaoss's full-sized avatar
🚀

Gary Chu schaoss

🚀
View GitHub Profile
@schaoss
schaoss / eye-dropper.js
Created March 24, 2023 02:57
eye-dropper
if (!window.__CUSTON_ED__) window.__CUSTON_ED__ = new EyeDropper()
window.__CUSTON_ED__.open()
.then(({ sRGBHex }) => {
console.log('%c ' + `%c ${sRGBHex}`, `background: ${sRGBHex}`, `background: unset`)
navigator?.clipboard?.writeText?.(sRGBHex)
})
.catch(() => {})
// bookmarklet: javascript:(function()%7Bwindow.__CUSTON_ED__%7C%7C(window.__CUSTON_ED__%3Dnew%20EyeDropper)%2Cwindow.__CUSTON_ED__.open().then((%7BsRGBHex%3Ac%7D)%3D%3E%7Bconsole.log(%60%25c%20%20%25c%20%24%7Bc%7D%60%2C%60background%3A%20%24%7Bc%7D%60%2C%22background%3A%20unset%22)%2Cnavigator%3F.clipboard%3F.writeText%3F.(c)%7D).catch(()%3D%3E%7B%7D)%3B%7D)()%3B
@schaoss
schaoss / v-devtools.js
Last active February 2, 2024 03:13
Force Open Vue Devtools
(() => {
const root = Array.from(document.querySelectorAll('*')).find((e) => e.__vue__ || e.__vue_app__);
const app = root?.__vue__ || root?.__vue_app__;
const devtools = window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
if (!app || !devtools) {
console.log(`Can't find vue app or devtools`);
return 0;
}
@schaoss
schaoss / nms.js
Created May 17, 2019 19:01
Natural Merge Sort
// 自然合併排序 - Natural Merge Sort
function nms(array) {
let resArr = cleanData(array)
while (resArr.length !== 1) {
let tmp = []
for (let i = 0; i < resArr.length; ) {
tmp.push(merge(resArr[i++], resArr[i++]))
}
resArr = tmp
}