(function (Scratch) { 'use strict'; // I LOVE SEA LIONS & SEALS const pinnipedFacts = [ "Sea lions and seals are part of a group called pinnipeds, meaning 'fin-footed'.", "Sea lions have external ear flaps, while true seals do not.", "Seals can hold their breath for up to two hours underwater.", "Sea lions can rotate their hind flippers forward to walk on land.", "The leopard seal is one of the ocean’s top predators.", "Harbor seals can sleep underwater and surface automatically to breathe.", "Sea lions are very vocal and use barks, growls, and roars to communicate.", "Some seals can dive over 1,500 meters deep.", "Walruses are also pinnipeds and are known for their long tusks.", "Sea lions are extremely intelligent and are often trained in zoos and aquariums.", "Seal whiskers are highly sensitive and help detect vibrations from prey.", "Pups are born on land or ice and rely on their mothers for warmth and food.", "The largest seal species is the southern elephant seal.", "Sea lions use their flippers to regulate body temperature.", "Some seals can slow their heart rate while diving to conserve oxygen.", "California sea lions can reach speeds of up to 25 mph in water.", "Seals have a thick layer of blubber to keep them warm in cold oceans.", "Sea lions are more agile on land compared to seals.", "Many seal species migrate long distances each year.", "Pinnipeds evolved from land-dwelling mammals millions of years ago.", "Crabeater seals primarily eat krill, not crabs.", "Sea lions often gather in large groups called colonies.", "Seals can close their nostrils underwater.", "Some seal species live in both the Arctic and Antarctic regions.", "Sea lions use body language to communicate dominance.", "Elephant seals are named for the males’ large nose.", "Seals can see well both above and below water.", "Sea lions have strong chest muscles for swimming.", "Pinnipeds play an important role in marine ecosystems.", "Some seals can live over 30 years in the wild." ]; let pinnipedSpecies = [ 'California sea lion', 'Steller sea lion', 'Australian sea lion', 'South American sea lion', 'Harbor seal', 'Gray seal', 'Leopard seal', 'Crabeater seal', 'Weddell seal', 'Ringed seal', 'Harp seal', 'Bearded seal', 'Elephant seal', 'Northern elephant seal', 'Southern elephant seal', 'Fur seal', 'Antarctic fur seal', 'Subantarctic fur seal', 'Monk seal', 'Hawaiian monk seal' ]; class PINNIPEDS { getInfo() { return { id: 'ginxiloveseals', name: 'SEA LIONS & SEALS', color1: '#2E8B57', // Sea Green color2: '#3CB371', // Medium Sea Green color3: '#1E6F50', blocks: [ { opcode: 'randomfact', blockType: Scratch.BlockType.REPORTER, text: 'random sea lion / seal fact from [FORMAT]', disableMonitor: true, arguments: { FORMAT: { type: Scratch.ArgumentType.STRING, menu: 'FORMAT_MENU' } } }, { opcode: 'arecool', blockType: Scratch.BlockType.BOOLEAN, text: 'are sea lions and seals cool?', disableMonitor: true, }, { opcode: 'speciesinfo', blockType: Scratch.BlockType.REPORTER, text: 'get info of species [SPECIES]', disableMonitor: true, arguments: { SPECIES: { type: Scratch.ArgumentType.STRING, menu: 'SPECIES_MENU' } } } ], menus: { FORMAT_MENU: { acceptReporters: true, items: [ 'source 1 (local. faster!)' ] }, SPECIES_MENU: { acceptReporters: true, items: pinnipedSpecies } } }; } randomfact(args) { return pinnipedFacts[Math.floor(Math.random() * pinnipedFacts.length)]; } arecool() { return true; } speciesinfo(args) { if (!pinnipedSpecies.includes(args.SPECIES)) { return "Species not found in list."; } let searchQuery = args.SPECIES; return fetch( "https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exlimit=1&titles=" + encodeURIComponent(searchQuery) + "&explaintext=1&exsectionformat=plain&format=json&origin=*" ) .then((response) => response.json()) .then((data) => { const pageId = Object.keys(data.query.pages)[0]; if (pageId === "-1") return "Could not find info for this species."; let extract = data.query.pages[pageId].extract; extract = extract.replace(/\s{2,}/g, ' '); return extract.split('.').slice(0, 2).join('.') + '. (Source: Wikipedia)'; }) .catch(() => 'Splash! Something went wrong.'); } } Scratch.extensions.register(new PINNIPEDS()); })(Scratch);