Skip to content

Commit

Permalink
add extension to list
Browse files Browse the repository at this point in the history
  • Loading branch information
redspacecat authored Aug 22, 2024
1 parent f4770ef commit 95b8be2
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lib/libraries/extensions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import issIcon from './snail-ide/iss.jpg';
import musicInsetIconURL from './music/music-small.svg';
import clfiveIcon from './cloudlink/cl5.svg';
import clomegaIcon from './cloudlink/clomega.svg';
import browserAndOSInfoIcon from './browserandosinfo/browserandosinfo.png';

import penIconURL from './pen/pen.png';
import penInsetIconURL from './pen/pen-small.svg';
Expand Down Expand Up @@ -1189,6 +1190,16 @@ const menuItems = [
description: 'Get the latitude and longitude of the International Space Station',
featured: true
},
{
name: 'Browser & OS Information',
snailExt: true,
extensionId: 'https://editor.snail-ide.com/browserandosinfo.js',
iconURL: browserAndOSInfoIcon,
tags: ['penguinmod'],
collaborator: 'redspacecat',
description: 'Get information about the user\'s browser and operating system',
featured: true
},
{
name: (
<FormattedMessage
Expand Down
101 changes: 101 additions & 0 deletions static/browserandosinfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Browser & OS Info
// Created by @redspacecat

(function(Scratch) {
'use strict';
let newScript = document.createElement("script")
newScript.src = "https://cdn.jsdelivr.net/npm/bowser@latest/bundled.js"
document.getElementsByTagName("head")[0].appendChild(newScript)

class BrowserAndOSInfo {
getInfo() {
return {
id: "browserinfo",
name: "Browser & OS Info",
color1: "#449462",
color2: "#35754d",
color3: "#35754d",
blocks: [
{
opcode: 'getBrowserName',
blockType: Scratch.BlockType.REPORTER,
text: 'get browser name',
disableMonitor: true,
},
{
opcode: 'getBrowserVersion',
blockType: Scratch.BlockType.REPORTER,
text: 'get browser version',
disableMonitor: true,
},
{
opcode: 'getOSName',
blockType: Scratch.BlockType.REPORTER,
text: 'get OS name',
disableMonitor: true,
},
{
opcode: 'getOSVersion',
blockType: Scratch.BlockType.REPORTER,
text: 'get OS version',
disableMonitor: true,
},
{
opcode: 'getPlatform',
blockType: Scratch.BlockType.REPORTER,
text: 'get platform',
disableMonitor: true,
},
{
opcode: 'getRenderingEngine',
blockType: Scratch.BlockType.REPORTER,
text: 'get rendering engine',
disableMonitor: true,
}
]
};
}

getBowser() {
try {
let b = bowser.getParser(window.navigator.userAgent)
return b
}
catch {
return "script still loading!"
}
}

getBrowserName() {
const browser = this.getBowser()
return browser.getBrowserName()
}

getBrowserVersion() {
const browser = this.getBowser()
return browser.getBrowserVersion()
}

getOSName() {
const browser = this.getBowser()
return browser.getOSName()
}

getOSVersion() {
const browser = this.getBowser()
return browser.getOS().versionName
}

getPlatform() {
const browser = this.getBowser()
return browser.getPlatformType()
}

getRenderingEngine() {
const browser = this.getBowser()
return browser.getEngineName()
}
}

Scratch.extensions.register(new BrowserAndOSInfo());
})(Scratch);

0 comments on commit 95b8be2

Please sign in to comment.