From 3804e9c0ca28a2171ab1c2ae06e29227f09545c0 Mon Sep 17 00:00:00 2001 From: Gabe <66077254+MrBrain295@users.noreply.github.com> Date: Wed, 10 Jul 2024 21:55:38 -0500 Subject: [PATCH] add joke bookmarklet https://github.com/MrBrain295/joke-bookmarklet --- fun/joke.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 fun/joke.js diff --git a/fun/joke.js b/fun/joke.js new file mode 100644 index 0000000..3e60314 --- /dev/null +++ b/fun/joke.js @@ -0,0 +1 @@ +javascript:async function joke(){try{var response=await fetch("https://official-joke-api.appspot.com/random_joke");if(!response.ok){throw new Error(`Response status: ${response.status }`)}var json=await response.json();return[json.setup,json.punchline]}catch(error){console.error(error.message);return["Error","Failed to fetch joke"]}}joke().then(jokeArray=>{alert(jokeArray[0]);alert(jokeArray[1])});