From fa51c991eb6fa6a22b016d3859e41693c3bcf529 Mon Sep 17 00:00:00 2001 From: GarboMuffin Date: Thu, 29 Jun 2023 21:35:48 -0500 Subject: [PATCH] Format --- extensions/NexusKitten/browserutils.js | 348 ++++++++++++------------- 1 file changed, 174 insertions(+), 174 deletions(-) diff --git a/extensions/NexusKitten/browserutils.js b/extensions/NexusKitten/browserutils.js index 81c3840183..ff047990e5 100644 --- a/extensions/NexusKitten/browserutils.js +++ b/extensions/NexusKitten/browserutils.js @@ -1,209 +1,209 @@ (function(Scratch) { - 'use strict'; + 'use strict'; - if (!Scratch.extensions.unsandboxed) { - throw new Error('Browser Utilities must run unsandboxed'); - } + if (!Scratch.extensions.unsandboxed) { + throw new Error('Browser Utilities must run unsandboxed'); + } - class nkbrowserutils { - getInfo() { - return { - id: 'nkbrowserutils', - name: 'Browser Utilities', - color1: '#504d6f', - color2: '#36344b', - blocks: [ - { - opcode: 'isonline', - blockType: Scratch.BlockType.BOOLEAN, - text: 'is online?' - }, - { - opcode: 'ismobile', - blockType: Scratch.BlockType.BOOLEAN, - text: 'is mobile?' - }, - '---', - { - opcode: 'getbrowser', - blockType: Scratch.BlockType.REPORTER, - text: 'user browser' - }, - { - opcode: 'geturl', - blockType: Scratch.BlockType.REPORTER, - text: 'current url' - }, - '---', - { - opcode: 'setfavicon', - blockType: Scratch.BlockType.COMMAND, - text: 'set page favicon to [ICO]', - arguments: { - ICO: { - type: Scratch.ArgumentType.STRING, - defaultValue: 'https://turbowarp.org/favicon.ico' - } + class BrowserUtils { + getInfo() { + return { + id: 'nkbrowserutils', + name: 'Browser Utilities', + color1: '#504d6f', + color2: '#36344b', + blocks: [ + { + opcode: 'isonline', + blockType: Scratch.BlockType.BOOLEAN, + text: 'is online?' + }, + { + opcode: 'ismobile', + blockType: Scratch.BlockType.BOOLEAN, + text: 'is mobile?' + }, + '---', + { + opcode: 'getbrowser', + blockType: Scratch.BlockType.REPORTER, + text: 'user browser' + }, + { + opcode: 'geturl', + blockType: Scratch.BlockType.REPORTER, + text: 'current url' + }, + '---', + { + opcode: 'setfavicon', + blockType: Scratch.BlockType.COMMAND, + text: 'set page favicon to [ICO]', + arguments: { + ICO: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'https://turbowarp.org/favicon.ico' } - }, - { - opcode: 'settitle', - blockType: Scratch.BlockType.COMMAND, - text: 'set page title to [TITLE]', - arguments: { - TITLE: { - type: Scratch.ArgumentType.STRING, - defaultValue: 'My Page' - } + } + }, + { + opcode: 'settitle', + blockType: Scratch.BlockType.COMMAND, + text: 'set page title to [TITLE]', + arguments: { + TITLE: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'My Page' } - }, - { - opcode: 'reload', - blockType: Scratch.BlockType.COMMAND, - text: 'reload page', - }, - '---', - { - opcode: 'tabactive', - blockType: Scratch.BlockType.BOOLEAN, - text: 'is tab active?', - }, - { - opcode: 'darkmode', - blockType: Scratch.BlockType.BOOLEAN, - text: 'is dark mode?', - }, - '---', - { - opcode: 'alertBlock', - blockType: Scratch.BlockType.COMMAND, - text: 'alert [STRING]', - arguments: { - STRING: { - type: Scratch.ArgumentType.STRING, - defaultValue: '' - } + } + }, + { + opcode: 'reload', + blockType: Scratch.BlockType.COMMAND, + text: 'reload page', + }, + '---', + { + opcode: 'tabactive', + blockType: Scratch.BlockType.BOOLEAN, + text: 'is tab active?', + }, + { + opcode: 'darkmode', + blockType: Scratch.BlockType.BOOLEAN, + text: 'is dark mode?', + }, + '---', + { + opcode: 'alertBlock', + blockType: Scratch.BlockType.COMMAND, + text: 'alert [STRING]', + arguments: { + STRING: { + type: Scratch.ArgumentType.STRING, + defaultValue: '' } - }, - { - opcode: 'inputPromptBlock', - blockType: Scratch.BlockType.REPORTER, - text: 'prompt [STRING]', - disableMonitor: true, - arguments: { - STRING: { - type: Scratch.ArgumentType.STRING, - defaultValue: '' - } + } + }, + { + opcode: 'inputPromptBlock', + blockType: Scratch.BlockType.REPORTER, + text: 'prompt [STRING]', + disableMonitor: true, + arguments: { + STRING: { + type: Scratch.ArgumentType.STRING, + defaultValue: '' } - }, - { - opcode: 'confirmationBlock', - blockType: Scratch.BlockType.BOOLEAN, - text: 'confirm [STRING]', - arguments: { - STRING: { - type: Scratch.ArgumentType.STRING, - defaultValue: '' - } + } + }, + { + opcode: 'confirmationBlock', + blockType: Scratch.BlockType.BOOLEAN, + text: 'confirm [STRING]', + arguments: { + STRING: { + type: Scratch.ArgumentType.STRING, + defaultValue: '' } } - ] - }; - } - async isonline() { - try { - const response = await Scratch.fetch('https://extensions.turbowarp.org/hello.txt'); - return true; - } catch (error){ - return false; - } - } - ismobile () { - const userAgent = navigator.userAgent; - return userAgent.includes('Android') || userAgent.includes('iPhone') || userAgent.includes('iPod') || userAgent.includes('iPad') || userAgent.includes('BlackBerry') || userAgent.includes('IEMobile') || userAgent.includes('Opera Mini'); + } + ] + }; + } + async isonline() { + try { + const response = await Scratch.fetch('https://extensions.turbowarp.org/hello.txt'); + return true; + } catch (error){ + return false; } - getbrowser () { - const userAgent = navigator.userAgent; - if (userAgent.includes('Edg')) { + } + ismobile () { + const userAgent = navigator.userAgent; + return userAgent.includes('Android') || userAgent.includes('iPhone') || userAgent.includes('iPod') || userAgent.includes('iPad') || userAgent.includes('BlackBerry') || userAgent.includes('IEMobile') || userAgent.includes('Opera Mini'); + } + getbrowser () { + const userAgent = navigator.userAgent; + if (userAgent.includes('Edg')) { return 'Microsoft Edge'; - } else if (userAgent.includes('OPR')) { + } else if (userAgent.includes('OPR')) { return 'Opera'; - } else if (userAgent.includes('Firefox')) { + } else if (userAgent.includes('Firefox')) { return 'Firefox'; - } else if (userAgent.includes('Windows NT')) { + } else if (userAgent.includes('Windows NT')) { return 'Internet Explorer'; - } else if (userAgent.includes('Chrome')) { + } else if (userAgent.includes('Chrome')) { return 'Chrome'; - } else { + } else { return 'Other'; - } } - geturl () { - try { + } + geturl () { + try { const currentUrl = window.location.href; return currentUrl; - } catch (error){ - return ''; - } + } catch (error){ + return ''; } + } - settitle (args) { - try { - document.title = args.TITLE; - } catch (error){ - } + settitle (args) { + try { + document.title = args.TITLE; + } catch (error){ } + } - setfavicon (args) { - try { - // Not sure why this code shows up with errors in visual studio, however it works. - var link = document.querySelector("link[rel~='icon']"); - if (!link) { - link = document.createElement('link'); - link.rel = 'icon'; - document.head.appendChild(link); - } - link.href = args.ICO; - } catch (error){ + setfavicon (args) { + try { + // Not sure why this code shows up with errors in visual studio, however it works. + var link = document.querySelector("link[rel~='icon']"); + if (!link) { + link = document.createElement('link'); + link.rel = 'icon'; + document.head.appendChild(link); } + link.href = args.ICO; + } catch (error){ } + } - reload () { - try { - location.reload(); - } catch (error){ - } + reload () { + try { + location.reload(); + } catch (error){ } + } - tabactive () { - try { - return !document.hidden; - } catch (error){ - return true; - } + tabactive () { + try { + return !document.hidden; + } catch (error){ + return true; } + } - darkmode () { - try { - return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; - } catch (error){ - return false; - } + darkmode () { + try { + return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; + } catch (error){ + return false; } + } - // The following blocks were originally from LMS Utilities, repurposed with permission. - alertBlock(args) { - alert(args.STRING); - } + // The following blocks were originally from LMS Utilities, repurposed with permission. + alertBlock(args) { + alert(args.STRING); + } - inputPromptBlock(args) { - return prompt(args.STRING); - } + inputPromptBlock(args) { + return prompt(args.STRING); + } - confirmationBlock(args) { - return confirm(args.STRING); - } + confirmationBlock(args) { + return confirm(args.STRING); } - Scratch.extensions.register(new nkbrowserutils()); - })(Scratch); + } + Scratch.extensions.register(new BrowserUtils()); +})(Scratch);