Skip to content

Instantly share code, notes, and snippets.

@ngseke
ngseke / thankful-rate.js
Last active March 18, 2022 03:03
計算外國 YouTuber 底下留言台灣感謝率
function calc () {
const patterns = [
{
regex: /(謝謝|感謝)/,
description: '普通感謝',
},
{
regex: /謝(.*?)(愛|喜)(.*?)灣/,
description: '精準感謝',
},
@ngseke
ngseke / number-separator.js
Last active October 12, 2021 03:38
以逗點分隔數字
const { format } = new Intl.NumberFormat('en-US')
console.log(format(14501405)) // 14,501,405
@ngseke
ngseke / fuck-interview-dot-tw.js
Last active July 28, 2021 09:10
fuck interview dot tw
function getVipButtons () {
return [...document.querySelectorAll('button.btn-exchange-vip')]
}
function getIsListLoaded () {
return document.querySelector('.interview-list').style.opacity === '1'
}
function goToNextPage () {
const $next = document.querySelector('.iw_pagination-item.iw_active').nextSibling.nextSibling.querySelector?.('a')
@ngseke
ngseke / observe.js
Last active June 27, 2021 06:06
Observe Youtube Chat Room Items
var $chatList = document
.querySelector('#chatframe')
.contentWindow
.document
.querySelector('#item-offset #items')
var observer = new MutationObserver(([{ target }]) => {
const items = [...target.querySelectorAll('yt-live-chat-text-message-renderer')]
.map($el => ({
img: $el.querySelector('#img').getAttribute('src'),
document.querySelector('#chat').setAttribute('style',`
opacity: .9;
position: fixed;
top: 1rem;
right: 1rem;
`)