Skip to content

Instantly share code, notes, and snippets.

@Explosion-Scratch
Explosion-Scratch / meta.js
Last active March 3, 2022 17:12
Generate meta
const generate = (meta) => {
return [
{ charset: "utf-8" },
{ lang: "en" },
{ name: "viewport", content: "width=device-width, initial-scale=1" },
{ name: "format-detection", content: "telephone=no" },
{ name: "title", content: meta.title },
{ name: "author", content: meta.author },
{
name: "keywords",
@Explosion-Scratch
Explosion-Scratch / ripple.js
Last active November 23, 2021 17:28
Ripple effect
function ripple(el, opts = {}) {
const time = opts.time || (+el.getAttribute("data-time") || 1000) * 3;
const color = opts.color || el.getAttribute("data-color") || "currentColor";
const opacity = opts.opacity || el.getAttribute("data-opacity") || ".3";
const event = opts.event || el.getAttribute("data-event") || "click";
el.style.overflow = "hidden";
el.style.position = "relative";
el.addEventListener(event, (e) => {
if (el.disabled) return;
var ripple_div = document.createElement("DIV");
@Explosion-Scratch
Explosion-Scratch / mediastream.js
Last active May 6, 2023 04:47
Greenscreen effect on media stream using canvas
//Helper functions:
// get('type', stream) returns the audio or video track from a stream.
// createStream(...tracks) returns a stream with all the tracks provided as parameters
async function manipulate(videoTrack, fn) {
let canvas = document.createElement("canvas");
let running = true;
const ctx = canvas.getContext("2d");
let video = document.createElement("video");
video.setAttribute("autoplay", true);
video.setAttribute("muted", true);
@Explosion-Scratch
Explosion-Scratch / Quizlet flashcards.js
Created October 12, 2021 23:55
Get Quizlet flashcards via API
async function quizlet(id){
let res = await fetch(`https://quizlet.com/webapi/3.4/studiable-item-documents?filters%5BstudiableContainerId%5D=${id}&filters%5BstudiableContainerType%5D=1&perPage=5&page=1`).then(res => res.json())
let currentLength = 5;
let token = res.responses[0].paging.token
let terms = res.responses[0].models.studiableItem;
let page = 2;
console.log({token, terms})
while (currentLength >= 5){
let res = await fetch(`https://quizlet.com/webapi/3.4/studiable-item-documents?filters%5BstudiableContainerId%5D=${id}&filters%5BstudiableContainerType%5D=1&perPage=5&page=${page++}&pagingToken=${token}`).then(res => res.json());
terms.push(...res.responses[0].models.studiableItem);
@Explosion-Scratch
Explosion-Scratch / Favicon counter.js
Last active May 6, 2023 04:47
Shows a number in the favicon like Discord and Gmail do.
/**
* Generates a data URL of the current favicon with a number added on top.
* @param {Object} options
* @param {String} [options.type = "image/png"] The mime type of the image to return.
* @param {String} [options.text = ""] The text to display on the favicon, if left blank will simply show a dot on the favicon.
* @param {String} [options.background = "white"] A CSS color for the background of the notification badge.
* @param {String} [options.color = "white"] A CSS color for the color of the text on the notification badge.
* @param {Number} [options.size = 10] The size of the notification badge. The badge generated will be size * 2 pixels in width and height, then added on top of the current favicon.
* @param {String} [options.pos = "bottom-right"] The position of the badge, either "bottom-right", "top-right", "bottom-left" or "top-left"
* @param {String} [options.font = "Monospace"] The font to use
@Explosion-Scratch
Explosion-Scratch / Compress string.js
Created November 1, 2021 18:51
Compress string using gzip and native browser APIs
function compress(string, encoding) {
const byteArray = new TextEncoder().encode(string);
const cs = new CompressionStream(encoding);
const writer = cs.writable.getWriter();
writer.write(byteArray);
writer.close();
return new Response(cs.readable).arrayBuffer();
}
function decompress(byteArray, encoding) {
@Explosion-Scratch
Explosion-Scratch / Authenticator.js
Created November 2, 2021 02:28
Generates an authenticator token based on a secret key. (Usually given in the QR code that apps have you scan)
async function getToken(key, options) {
let { default: JsSHA } = await import(
"https://cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/jssha.js"
);
options = {
period: 30,
algorithm: "SHA-1",
digits: 6,
timestamp: Date.now(),
...options,
@Explosion-Scratch
Explosion-Scratch / Remove watch later.js
Created November 4, 2021 16:25
Remove all videos from watch later (YouTube)
PLEASE_STOP = false;
//set PLEASE_STOP to true to stop removing videos
while (window.PLEASE_STOP === false) {
document.querySelector("ytd-playlist-video-renderer .yt-icon-button").click();
await new Promise((r) => setTimeout(r, 100));
[...document.querySelectorAll("ytd-menu-popup-renderer tp-yt-paper-item")]
.find((i) => i.innerText.includes("Remove from"))
.click();
await new Promise((r) => setTimeout(r, 400));
}
@Explosion-Scratch
Explosion-Scratch / Tiny helpers.json
Created November 21, 2021 17:52
A total JSON list of all the tiny helpers from stefanjudis/tiny-helpers
{
"0to255.json": {
"name": "0to255",
"desc": "Lighten and darken colors easily",
"url": "https://www.0to255.com/",
"tags": [
"Color"
],
"maintainers": [],
"addedAt": "2020-01-24"
@Explosion-Scratch
Explosion-Scratch / Top 1m.json
Last active April 29, 2025 17:55
The top 1 million sites.
["google.com","youtube.com","tmall.com","qq.com","baidu.com","sohu.com","taobao.com","360.cn","amazon.com","jd.com","facebook.com","yahoo.com","wikipedia.org","weibo.com","zoom.us","sina.com.cn","xinhuanet.com","live.com","microsoft.com","office.com","reddit.com","panda.tv","netflix.com","instagram.com","zhanqi.tv","google.com.hk","canva.com","csdn.net","myshopify.com","alipay.com","force.com","microsoftonline.com","vk.com","yahoo.co.jp","coinmarketcap.com","stackoverflow.com","naver.com","linkedin.com","bongacams.com","twitter.com","adobe.com","tianya.cn","bing.com","yy.com","ebay.com","huanqiu.com","salesforce.com","chaturbate.com","amazon.in","twitch.tv","whatsapp.com","aliexpress.com","amazon.co.jp","yandex.ru","17ok.com","1688.com","mail.ru","tiktok.com","dropbox.com","tradingview.com","wordpress.com","discord.com","aparat.com","tribunnews.com","babytree.com","etsy.com","msn.com","chase.com","indeed.com","zoho.com","walmart.com","spotify.com","upwork.com","google.co.in","freepik.com","amazonaws.com","pik