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
import puppeteer from 'puppeteer'; | |
const browser = await puppeteer.launch({ | |
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', | |
headless: false, | |
args: [ | |
'--window-size=1818,1328', | |
"--no-sandbox", | |
"--disable-setuid-sandbox", | |
"--disable-dev-shm-usage", |
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
import puppeteer from 'puppeteer'; | |
const browser = await puppeteer.launch({ | |
headless: false, | |
args: [ | |
'--window-size=1818,1328', | |
"--no-sandbox", | |
"--disable-setuid-sandbox", | |
"--disable-dev-shm-usage", | |
"--disable-accelerated-2d-canvas", |
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 PRODUCT_ANCHOR_ELEMENT_SELECTOR = '[data-component="ProductCardLink"]'; | |
// get all <a> elemenets in a list of product links | |
const links = Array.from(document.querySelectorAll(PRODUCT_ANCHOR_ELEMENT_SELECTOR)); | |
links.map(link => { | |
link.addEventListener('click', async (e) => { | |
e.preventDefault(); | |
const image = link.querySelector('img'); | |
// View Transition necessary styles |
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
/* | |
* This script migrates all messages and users | |
* from a Sendbird supergroup channel to a group channel | |
* by creating a new group channel and deleting the old supergroup channel. | |
* | |
* Note: make sure you have chat history enabled for newly joined members | |
* Enable it by selecting an App from the Dashboard and toggle the checkbox under | |
* Settings > Chat > Group Channels > Chat history | |
* | |
* To use this script, you need to change APP_ID and API_TOKEN below |
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
export default [ | |
'www/index.html', | |
'www/main.css', | |
'www/main.js', | |
'www/icons/ic-add-room.svg', | |
'www/icons/ic-arrow-down-right-24.svg', | |
'www/icons/ic-arrow-left.svg', | |
'www/icons/ic-call-filled-active.svg', | |
'www/icons/ic-call-filled-deactive.svg', | |
'www/icons/ic-call-filled-purple.svg', |
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
async function copyImageToClipboard(img) { | |
const src = img.src | |
const imageMimeType = getImageMimeTypeFromUrl(src) | |
const blob = imageMimeType === 'image/svg' | |
? await getTextBlobFromUrl(src) | |
: await getImageBlobFromUrl(src) | |
await navigator.clipboard.write([ | |
new ClipboardItem({ | |
[blob.type]: blob |
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 (isSafari()) { | |
const imageMimeType = getImageMimeTypeFromUrl(src) | |
await navigator.clipboard.write([ | |
new ClipboardItem({ | |
[imageMimeType]: getImageBlobFromUrl(src) | |
}) | |
]) | |
} |
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 getImageMimeTypeFromUrl(url) { | |
return `image/${url.match(/([a-z]+)$/)[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
document.querySelector('.copy-button').addEventListener('click', async () => { | |
const src = document.querySelector('.image-to-copy').src | |
try { | |
const blob = await getImageBlobFromUrl(src) | |
await navigator.clipboard.write([ | |
new ClipboardItem({ | |
[blob.type]: blob | |
}) | |
]) | |
alert('Image copied to clipboard!') |
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
async function getImageBlobFromUrl(url) { | |
const fetchedImageData = await fetch(url) | |
const blob = await fetchedImageData.blob() | |
return blob | |
} |
NewerOlder