-
Notifications
You must be signed in to change notification settings - Fork 169
Alert Extension #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Alert Extension #257
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| (function (Scratch) { | ||
| 'use strict'; | ||
|
|
||
| class AlertExtension { | ||
| constructor() {} | ||
|
|
||
| showAlert(args) { | ||
| alert(args.TEXT); | ||
| } | ||
|
|
||
| promptText(args) { | ||
| return prompt(args.MESSAGE || 'Insert text here:'); | ||
| } | ||
|
|
||
| confirmAction(args) { | ||
| return confirm(args.MESSAGE || 'are you sure?'); | ||
| } | ||
|
|
||
| WebExt_DisplayNotification(args) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the notifications part of this extension seems a bit pointless since there is already an extension for it on the TurboWarp Gallery, one of our listed galleries in penguinmod |
||
| new Notification(args.TITLE, { | ||
| body: args.MESSAGE, | ||
| }); | ||
| setTimeout(() => { | ||
| }, args.DURATION * 1000); | ||
| } | ||
|
|
||
| WebExt_DisplayNotificationWithIcon(args) { | ||
| new Notification(args.TITLE, { | ||
| body: args.MESSAGE, | ||
| icon: args.URL | ||
| }); | ||
| setTimeout(() => { | ||
|
|
||
| }, args.DURATION * 1000); | ||
| } | ||
|
|
||
| WebExt_canDisplayNotification() { | ||
| return Notification.permission === 'granted'; | ||
| } | ||
|
|
||
| getInfo() { | ||
| const iconURI = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgIAAAHSBAMAAABsvb5NAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAqUExURQAAALMSErYUFLYVFbcVFf////vY2PWqqu98fOpQUOIbG9YZGcgXF7cWFn3W+gkAAAAFdFJOUwAbQm67kaCjrAAADXFJREFUeNrk28FqE0Ecx/FJ2mtgUa+F2J4DkfZaSO15j1v0AUr1BYr6AAreq9AX0EziC0TzAqGBxOzJZN7FImJtk+lv+V/KfPf7CMv85zM72bgHrbG7t7+/+9TVtEcHefhbud92tWsvD7c6rtlKeJyHtY4zV5saB2Fjz1xNauYh0rGrRVt5iLbIHL+tcF9lVusHoB8B/wHwB6EZdAs0g3mo0HPH7TBUquuoPQkVa7M3gRpvBXmo3BF9BnRt+AzoFnQHdF34YVBX0rdB3RF8G9SVGfw4rJs7UjvBUEZaAsHSnL4L6DI4BLqeo7QdbJX0JaDrwY+DugX9jUDXhr8U6ub005Auo++Dq6vrxF5I3gevRv5P36fovbATIq1G/l8/xF6IfCVY+v8bxJbBDHAeFA9APIKSehhY+rsNxBjAhmDl1xuKIwFrCPxNajsskUMw8RubAsegITcBvRXMgMehkY/0jXco2hEzIOYA8G6Qawe0Bz3Ai7FYAmIR/HTp1hJLoNoiKGEWTvy9TVEeNsQSqLoIZqgD4S8vQnnY0WeB9cYkD3NxHKx8MOyBLJx42ZTjYSuyD4qGHA8PI/ugCvNdVSOyD8rGFA+3I0MgG1I87ESGQEfxMI8MgW7M8HArNgS6IcPDHfMQ+AHDw8Pocch0KOoiLPTR9H3hnGDh0ldtQPCwI4ZAjAHAwyAsNHgIt1B7SLdQHwtdWuViG8B72BQWmjykW6g9xFuoPaRbqD2kW6g9pFuoPcRfjmgP6RZqD+EWag9L+uWIHoM24HIE7qG2kO+htpDvobaQ72FTD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9nZMMb+v5AV+H2vxAPycZXEUEvhNk4KkgOoC+k5MMltEk1X1hptTKq/CkUbcliyn5AYOOuJDNX9HWi0+cVm1Nw0GjfksWM/LDZk+yeQyWDWdMdoQVtZYJAhkGMjBtIOwkMheU+j+BdQ/cZteqn8Bt8yaadR4/gVW9nlLQgSeCOtf1DgpBB863QLyBobMO8q6lz0C8t7m/bvtz8Gq5DrIK9xHV+beVAOL9fN21gEACEO9o7KxbjeDtuiGNCxrrvGuBEd4smwCsgv2EAYM3af/+3y7XjdkPLvCIIfyXapbrO9ML9pRmlVWwtz2v7Af32GSSeHF5P8+HILBBPtkPtvfnlV5wkUs2ie+w6Ob6HqzTz+89mPW7cK8IcpDXT8D+Efg/gbx/BKsizv2cfgJ5/whuiqZ08/sWyPPD8OeiOZ2MXoP+y9B/BuL0M3oG4nQO8vGA7wP/JRDnQZsB3PaKz8i3LQawW3xWvs8AQJ4IVvUjkOe74JfiS9JtnRRvfyi+LJ2fWvYD6BVfnAcHLfr3PyxQHjxryb9/t8DpPE4dwrOn9X8/pvDNo8dPE8yPjx49/JyH/z3mQ63Eeg9aMwAAAABJRU5ErkJggg=='; | ||
|
|
||
| return { | ||
| id: 'alertExtension', | ||
| name: 'Alert Extension', | ||
| color1: '#841919', | ||
| color2: '#9E2D2D', | ||
| color3: '#6B1111', | ||
| menuIconURI: iconURI, | ||
| blockIconURI: iconURI, | ||
| blocks: [ | ||
| { | ||
| blockType: "label", | ||
| text: "Alerts", | ||
| }, | ||
| { | ||
| opcode: 'showAlert', | ||
| blockType: Scratch.BlockType.COMMAND, | ||
| text: 'alert [TEXT]', | ||
| arguments: { | ||
| TEXT: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| defaultValue: "text" | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| opcode: 'promptText', | ||
| blockType: Scratch.BlockType.REPORTER, | ||
| text: 'prompt [MESSAGE]', | ||
| arguments: { | ||
| MESSAGE: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| defaultValue: 'What is your name?' | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| opcode: 'confirmAction', | ||
| blockType: Scratch.BlockType.BOOLEAN, | ||
| text: 'confirm [MESSAGE]', | ||
| arguments: { | ||
| MESSAGE: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| defaultValue: 'Are you sure?' | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| blockType: "label", | ||
| text: "Notifications", | ||
| }, | ||
| { | ||
| opcode: 'WebExt_DisplayNotification', | ||
| blockType: Scratch.BlockType.COMMAND, | ||
| text: 'display notification with title: [TITLE] and message: [MESSAGE] during [DURATION] seconds', | ||
| func: 'WebExt_DisplayNotification', | ||
| arguments: { | ||
| TITLE: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| defaultValue: 'title' | ||
| }, | ||
| MESSAGE: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| defaultValue: 'message' | ||
| }, | ||
| DURATION: { | ||
| type: Scratch.ArgumentType.NUMBER, | ||
| defaultValue: 3 | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| opcode: 'WebExt_DisplayNotificationWithIcon', | ||
| blockType: Scratch.BlockType.COMMAND, | ||
| text: 'display notification with title: [TITLE] and message: [MESSAGE] during [DURATION] seconds and [URL] as icon', | ||
| func: 'WebExt_DisplayNotificationWithIcon', | ||
| arguments: { | ||
| TITLE: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| defaultValue: 'title' | ||
| }, | ||
| MESSAGE: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| defaultValue: 'message' | ||
| }, | ||
| DURATION: { | ||
| type: Scratch.ArgumentType.NUMBER, | ||
| defaultValue: 3 | ||
| }, | ||
| URL: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| defaultValue: 'URL' | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| opcode: 'WebExt_canDisplayNotification', | ||
| blockType: Scratch.BlockType.BOOLEAN, | ||
| text: 'can display notifications?', | ||
| arguments: {} | ||
| } | ||
| ] | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| Scratch.extensions.register(new AlertExtension()); | ||
| })(Scratch); | ||
|
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename your files so they dont have spaces in the name