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
const useKeyboardBindings = map => { | |
useEffect(() => { | |
const handlePress = e => { | |
const handler = map[e.key]; | |
if (e.repeat) return; | |
if (typeof handler === 'function') { | |
handler(); | |
} | |
}; |
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
const loadData = async (url) => { | |
var data = localStorage.getItem(url); | |
if (data) { // check if expired | |
data = JSON.parse(data); | |
if (Date.now() - data.timestamp > 600000) { // 10mins | |
localStorage.removeItem(url); | |
data = null; | |
} | |
} |
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
let hashtag = "MIDJOURNEY"; | |
const removePostsWithHashtag = (posts, hashtag) => { | |
let docs = posts; | |
docs.forEach((doc => { | |
let caption = doc.innerText.toUpperCase(); | |
let hasHashtag = caption.indexOf(hashtag) !== -1 | |
if(!hasHashtag) return; | |
let thisPost = doc.closest(".artdeco-card"); |
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
if(window.location.href === "https://www.youtube.com"){ | |
window.location = "https://www.youtube.com/feed/subscriptions" | |
} | |
const getCurrentVideoID = () => { | |
let currentUrl = window.location.href; | |
let currentVideoID = currentUrl.split("https://www.youtube.com/watch?v=", -1)[1]; | |
return currentVideoID | |
} |
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
// pause video playback when not in view | |
useEffect(() => { | |
let observerOptions = { | |
rootMargin: "0px", | |
threshold: [0.25, 0.75] // start playing when 25% and 75% of the element is in view | |
}; | |
// watch all selected videos and control playback when they enter the viewport | |
let handlePlay = (entries, videoObserver) => { | |
entries.forEach((entry) => { |
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
//Handle input field text after user stops typing (300ms delay), and only execute code if there is new text | |
// Create a new timeout | |
let inputTimeout = null; | |
// Create a variable to store old text | |
let oldInputText = ''; | |
inputField.addEventListener('keyup', function () { | |
// Clear the timeout on keypress |
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 $(element){ | |
return document.querySelectorAll(element); | |
} | |
function getSvg(url){ | |
fetch(url) | |
.then(function(response) { | |
response.text().then(function(text) { | |
if(document.hasFocus()){ | |
navigator.clipboard.writeText(text); |
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 $(elem){ | |
return document.querySelectorAll(elem); | |
} | |
var notificationBtn = $('button._1aYva')[0]; | |
notificationBtn.addEventListener('click', function(){ | |
var notificationsVisible = setInterval(function() { | |
if ($('._35qCx button:nth-child(2)')[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
// fileSaver | |
(function(a,b){if("function"==typeof define&&define.amd)define([],b);else if("undefined"!=typeof exports)b();else{b(),a.FileSaver={exports:{}}.exports}})(this,function(){"use strict";function b(a,b){return"undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(a,b,c){var d=new XMLHttpRequest;d.open("GET",a),d.responseType="blob",d.onload=function(){g(d.response,b,c)},d.onerror=function(){console.error("could not download file")},d.send()}function d(a){var b=new XMLHttpRequest;b.open("HEAD",a,!1);try{b.send()}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"))}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b)}}var f="object"= |
NewerOlder