This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onKeypress(event: KeyboardEvent) { | |
const isEnter = ['Enter', '\n'].includes(event.key) | |
if (isEnter && !event.shiftKey) { | |
// document.execCommand('insertLineBreak') // short and more solid alternative, despide of deprecation | |
const selection = window.getSelection() | |
if (selection) { | |
const range = selection.getRangeAt(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parse_git_branch() { | |
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p' | |
} | |
setopt PROMPT_SUBST | |
export PROMPT='%F{grey}%n%f %F{cyan}%~%f %F{green}$(parse_git_branch)%f %F{normal}$%f ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scroll down fully | |
var songs = document.querySelectorAll('.audio_row'); | |
var playlistId = '15359214_51903820'; | |
for (var i = songs.length - 1; i >= 0; i--) { | |
console.log(i, 'more'); | |
const mouseoverEvent = new Event('mouseover'); | |
songs[i].dispatchEvent(mouseoverEvent); | |
await new Promise((a)=>setTimeout(a, 500)); | |
songs[i].querySelector('.audio_row__action_more').click(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getBoundingClientRect(element) { | |
return new Promise(resolve => { | |
const observer = new IntersectionObserver(([entity]) => { | |
observer.unobserve(element); | |
observer.disconnect(); | |
resolve(entity.boundingClientRect); | |
}); | |
observer.observe(element); | |
}); |