Skip to content

Instantly share code, notes, and snippets.

View Explosion-Scratch's full-sized avatar

--Explosion-- Explosion-Scratch

View GitHub Profile
@BoomerScratch
BoomerScratch / _scratch-view-stepping.user.js
Last active July 7, 2020 22:20
View stepping in Scratch editor
// ==UserScript==
// @name Scratch - view stepping
// @namespace none
// @version 1.1
// @description Allows you to see which block currently executes in the Scratch editor (scratch.mit.edu), which is useful for debugging.
// @author BoomerScratch
// @match https://scratch.mit.edu/projects/*
// @grant none
// @run-at document-start
// @homepageURL https://gist.github.com/BoomerScratch/0592337050810244236d69a4267b3913
[class*="stage-header_stage-menu-wrapper"][class*="box_box"] {
flex-direction: row-reverse;
}
[class*="gui_body-wrapper"], [class*="menu-bar_menu-bar_"] {
background: #c0c3c6;
}
[class*="menu-bar_menu-bar_"] *{
color:#4c4c4c;
background: transparent;
@Explosion-Scratch
Explosion-Scratch / preload.js
Last active April 28, 2021 18:24
Preloads a webpage through an iframe.
//Set window.load and window.show so that the child iframe element can access those functions.
window.load = load;
window.show = show;
//Convert all links to preload on hover.
[...document.querySelectorAll("a")].forEach((a) => {
a.addEventListener("click", (e) => {
e.preventDefault();
show(a.href);
});
a.addEventListener("mouseenter", (e) => {
@Explosion-Scratch
Explosion-Scratch / spreadsheets.md
Last active September 6, 2021 19:17
Fetch data from google sheets as a JavaScript object!!

Get data from google sheets!

This script gets data from a google sheets table and returns it in easy to use JSON. Tables must have a header 😃

How to get the spreadsheet ID:

Publish it to the web:

image

The ID is in the link that publish to the web gives you, NOT the webpage URL

@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 / hotreload.js
Created July 10, 2022 19:26
Hotreload a page (uses fetch to check for updates, automatically senses resources)
(async ({
interval = 500,
method = "fetch",
useIframe = false,
resources = [],
autoDetect = true,
resourceTypes = ["navigation", "script", "resource", "link", "img", "other"],
}) => {
if (autoDetect) {
resources = performance
@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 / SvelteComponent.svelte
Last active May 6, 2023 04:48
Get metadata from a URL and parse it.
<script>
import {onMount} from "svelte";
export let link = "";
let m, title, description, img, img_el;
onMount(async () => {
m = await meta(link);
m = parseMeta(m);
title = m.title;
description = m.description;
img = m.image;
((window) => {
var _fetch = window.fetch; //Get the original fetch functionm
window.fetch = (url, opts = {}) => {
if (!window.FETCH_CACHE) {
window.FETCH_CACHE = {};
}
return new Promise((resolve) => {
/*
Generate a sort of unique key about this fetch request.
This file has been truncated, but you can view the full file.
[
{"question":"A ____ atom in an atomic clock beats 9,192,631,770 times a second","answer":"cesium","money":1000},
{"question":"A ____ generates temperatures five times hotter than those found on the sun's surface","answer":"lightning bolt","money":1000},
{"question":"A ____ is a pact between a secular authority & the church","answer":"concordat","money":1000},
{"question":"A ____ is the blue field behind the stars","answer":"canton","money":1000},
{"question":"A ____ occurs when all the planets of the our Solar System line up","answer":"sysygy","money":1000},
{"question":"A ____ razor removed from King Tut's Tomb was still sharp enough to be used","answer":"golden","money":1000},
{"question":"A ____ takes 33 hours to crawl one mile","answer":"snail","money":1000},
{"question":"A ____ women can get a divorce if her husband doesn't give her coffee","answer":"saudi arabian","money":1000},
{"question":"A ____ written to celebrate a wedding is called a epithalamium","answer":"poem","money":1000},