{"id":20027712,"url":"https://github.com/cragglesg/webscript","last_synced_at":"2026-01-02T23:44:39.810Z","repository":{"id":252219701,"uuid":"837669367","full_name":"CragglesG/WebScript","owner":"CragglesG","description":"webscript. interact with the web.","archived":false,"fork":false,"pushed_at":"2024-08-30T17:18:18.000Z","size":551,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T12:27:34.401Z","etag":null,"topics":["hackclub","javascript","programming-language","web"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CragglesG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-03T16:53:04.000Z","updated_at":"2024-08-30T14:34:48.000Z","dependencies_parsed_at":"2024-08-29T22:09:05.431Z","dependency_job_id":"3aa3aad5-c6fb-4f8c-8f00-02fa333a0b0f","html_url":"https://github.com/CragglesG/WebScript","commit_stats":null,"previous_names":["cragglesg/easel","cragglesg/webscript"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CragglesG%2FWebScript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CragglesG%2FWebScript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CragglesG%2FWebScript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CragglesG%2FWebScript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CragglesG","download_url":"https://codeload.github.com/CragglesG/WebScript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243964001,"owners_count":20375695,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hackclub","javascript","programming-language","web"],"created_at":"2024-11-13T09:11:28.520Z","updated_at":"2026-01-02T23:44:39.769Z","avatar_url":"https://github.com/CragglesG.png","language":"JavaScript","readme":"# WebScript\n\nWebScript is an in-development programming language for interacting with the web.\n\n\u003c!--_Hack Club Arcade Reviewers, see [here](#arcade-reviewers) (not for showcase, only scrapbook)_ !--\u003e\n\n_Found a bug? Want a new feature? [Create an issue!](https://github.com/CragglesG/WebScript/issues/new) (Please check for an existing one first to avoid duplicates!)_\n\n_Want to contribute? You can find good first issues [here](https://github.com/CragglesG/WebScript/contribute)._\n\n[![asciicast](https://asciinema.org/a/53pbwoqLIowySMPDPQDq7oeiy.svg)](https://asciinema.org/a/53pbwoqLIowySMPDPQDq7oeiy)\n\n## Table of Contents\n\n- [Installation Guide](#installation-guide)\n  - [Linux](#linux)\n  - [macOS](#macos)\n  - [Windows](#windows)\n- [Command Line Usage](#command-line-usage)\n- [Syntax](#syntax)\n  - [Standard Library](#standard-library)\n    - [request](#request)\n    - [crypto](#crypto)\n- [Implementation Details](#implementation-details)\n\n## Installation Guide\n\nWhile the installation process is quick and straightfoward, it differs slightly by OS. Please skip to the installation guide for the OS you are using.\n\n### Linux\n\nTo quick install WebScript to `~/.webscript`, run the following command:\n\n```\nwget https://github.com/CragglesG/WebScript/blob/main/linux/install.sh \u0026\u0026 chmod +x install.sh \u0026\u0026 ./install.sh\n```\n\nAfter this command has executed, you can run WebScript using the command `webscript`.\n\n---\n\nIf you would rather inspect `install.sh` first to see what's happening under the hood, you can do so by running the above commands separately. This first command downloads `install.sh` from this repository:\n\n```\nwget https://github.com/CragglesG/WebScript/blob/main/linux/install.sh\n```\n\nIf you would like to inspect `install.sh`, you can do this now. To make this file executable so that we can run it, we need to change its permissions:\n\n```\nchmod +x install.sh\n```\n\nLastly, we'll run the file, which will automatically install WebScript into the `.webscript` folder inside your home directory:\n\n```\n./install.sh\n```\n\nDone! You can now use the command `webscript` to run WebScript.\n\n### macOS\n\n_WARNING: This has not yet been tested and may not work as intended._\n\nThis process is much the same as the process for Linux, with the only difference being slightly different download links.\n\n**WebScript requires that your default shell is set to zsh. If you are running macOS Catalina 10.15 or higher, and you have not changed your default shell, you are already using zsh.**\n\nTo quick install WebScript to `~/.webscript`, run the following command:\n\n```\nwget https://github.com/CragglesG/WebScript/blob/main/macos/install.sh \u0026\u0026 chmod +x install.sh \u0026\u0026 ./install.sh\n```\n\nAfter this command has executed, you can run WebScript using the command `webscript`.\n\n---\n\nIf you would rather inspect `install.sh` first to see what's happening under the hood, you can do so by running the above commands separately. This first command downloads `install.sh` from this repository:\n\n```\nwget https://github.com/CragglesG/WebScript/blob/main/macos/install.sh\n```\n\nIf you would like to inspect `install.sh`, you can do this now. To make this file executable so that we can run it, we need to change its permissions:\n\n```\nchmod +x install.sh\n```\n\nLastly, we'll run the file, which will automatically install WebScript into the `.webscript` folder inside your home directory:\n\n```\n./install.sh\n```\n\nDone! You can now use the command `webscript` to run WebScript.\n\n### Windows\n\n_WARNING: This has not yet been tested and may not work as intended._\n\nBefore installing WebScript, you must enable execution of local scripts. You can do this using the following command in PowerShell (Run as administrator):\n\n```\nSet-ExecutionPolicy RemoteSigned\n```\n\nTo install WebScript run the following in PowerShell (Do not run as administrator):\n\n```\nNew-Item -ItemType Directory -Path \"$env:USERPROFILE/.webscript\"\ngit clone \"https://github.com/CragglesG/WebScript/\" \"$env:USERPROFILE/.webscript\"\n[Environment]::SetEnvironmentVariable(\"Path\", $env:Path + \";$env:USERPROFILE/.webscript/windows/\", \"User\")\n```\n\nDone! You can now use the command `webscript` to run WebScript.\n\n## Command Line Usage\n\nOnce installed, you can use WebScript with the `webscript` command. To enter REPL, simply run `webscript` alone:\n\n```\nwebscript\n```\n\nTo run a WebScript file, run the following, replacing `FILE` with the desired filename:\n\n```\nwebscript FILE\n```\n\nWebScript's debug mode will output the AST (Abstract Syntax Tree) and tokens generated into the files `ast.json` and `tokens.json`, respectively. This can be useful for debugging while contributing. To run a file in debug mode, add the flag `--dbg`:\n\n```\nwebscript FILE --dbg\n```\n\n## Syntax\n\nWebScript currently adopts a very similar syntax to [Hack Club's Easel](https://github.com/hackclub/easel/tree/main/languages/easel). (WebScript was orignally made using the tutorial, but is constantly being modified and improved.)\nIt also shares some similarities with the language it is written in, JavaScript. Below is a table of the current WebScript syntax:\n\n| Operation                 | Syntax                                                             | Notes                                                                                                                 |\n| ------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------- |\n| Declare/Mutate Variable   | `prepare NAME as VALUE`                                            | This syntax is also used to modify object attributes, for example: `prepare obj.attr as 'attr'`                       |\n| Define Struct             | `type NAME has { PROPERTIES }`                                     | -                                                                                                                     |\n| Create Instance of Struct | `prep NAME(PROPERTIES)`                                            | `NAME` should be the name of the struct. References to the struct after instance creation will refer to the instance. |\n| Define Function           | `func NAME needs (PARAMS) { BODY }`                                | Whitespace is always ignored, but it is recommended for readability.                                                  |\n| Return from Function      | `return VALUE`                                                     | -                                                                                                                     |\n| Loop through Range        | `loop COUNTER through (START, END) { BODY }`                       | `COUNTER` should usually, by convention, be `i`.                                                                      |\n| Loop While True           | `while (CONDITION) { BODY }`                                       | -                                                                                                                     |\n| If/Else-if/Else Statement | ` if (CONDITION) { BODY } elif (CONDITION) { BODY } else { BODY }` | -                                                                                                                     |\n| Exit REPL                 | `exit()`                                                           | Only available in REPL mode.                                                                                          |\n| Equivalent                | `==`                                                               | -                                                                                                                     |\n| Not Equivalent            | `!=`                                                               | -                                                                                                                     |\n| Greater Than              | `\u003e`                                                                | -                                                                                                                     |\n| Less Than                 | `\u003c`                                                                | -                                                                                                                     |\n| Addition                  | `+`                                                                | -                                                                                                                     |\n| Multiplication            | `*`                                                                | -                                                                                                                     |\n| Subtraction               | `-`                                                                | -                                                                                                                     |\n| Division                  | `/`                                                                | -                                                                                                                     |\n| Or                        | `\\|\\|`                                                             | -                                                                                                                     |\n| Comment                   | `//`                                                               | -                                                                                                                     |\n| String                    | `''` or `\"\"`                                                       | Strings should be ended with the same type of quotation mark they begun with.                                         |\n\n### Standard Library\n\nWebScript's Standard Library provides numerous helpful methods and objects for you to use. Below is a table of all included methods and objects:\n\n| Name      | Use                            | Description                                                                                    |\n| --------- | ------------------------------ | ---------------------------------------------------------------------------------------------- |\n| `display` | `display(ARGS)`                | Prints `ARGS` to the console using `console.log()`. Accepts multiple arguments.                |\n| `random`  | `random([MIN, MAX])`           | Chooses a random number between `MIN` and `MAX` using `Math.random()`.                         |\n| `round`   | `round(NUMBER)`                | Rounds `NUMBER` to the nearest whole number using `Math.round()`.                              |\n| `request` | `prepare NAME as request(URL)` | `request` is a request object that utilises `XMLHttpRequest`. Use is further documented below. |\n| `crypto`  | `prepare NAME as crypto`       | `crypto` is a BlockchairAPI object. Use is further documented below                            |\n\n#### `request`\n\nThe `request` object is provided in the Standard Library to allow GET, POST, PUT, and DELETE requests to be easily sent through HTTP. A table of all attributes and methods is provided below:\n\n| Method/Attribute                        | Use                             | Description                                                    |\n| --------------------------------------- | ------------------------------- | -------------------------------------------------------------- |\n| `request`                               | `prepare NAME as request(URL)`  | Prepares `NAME` as a `request` object with `URL` as `this.url` |\n| `request.get(headers=[])`               | `request.get(HEADERS)`          | Sends a GET request with `HEADERS` to `this.url`               |\n| `request.post(body=null, headers=[]`    | `request.post(BODY, HEADERS)`   | Sends a POST request with `BODY` and `HEADERS` to `this.url`   |\n| `request.put(body=null, headers=[])`    | `request.put(BODY, HEADERS)`    | Sends a POST request with `BODY` and `HEADERS` to `this.url`   |\n| `request.delete(body=null, headers=[])` | `request.delete(BODY, HEADERS)` | Sends a DELETE request with `BODY` and `HEADERS` to `this.url` |\n\nIf you find the above table unhelpful or hard to understand, here's a step-by-step example of how to use `request` to make a GET request to Google:\n\nFirst, we need to prepare a `request` object with our chosen URL. We can do this by creating a variable:\n\n```\nprepare google as request('https://www.google.ie')\n```\n\nNow that we've prepared our request, we can send it! We're going to use a GET request to retrieve Google's homepage and print the data to the console:\n\n```\nprepare data as google.get()\ndisplay(data)\n```\n\nNotice how we didn't need to use any custom request headers, so we didn't pass in any arguments. If we wanted to include request headers, we would do it like this:\n\n```\ngoogle.get([YOUR_HEADERS_HERE])\n```\n\n#### `crypto`\n\nThe `crypto` object allows you to query the Blockchair API directly from WebScript (up to 1400 times/day without an API key) to retrieve information from 14 blockchains. A table of all attributes and methods is provided below:\n\n| Method/Attribute                                     | Use                                  | Description                                                                                       |\n| ---------------------------------------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------- |\n| `crypto`                                             | `prepare NAME as crypto`             | Prepares `NAME` as a `BlockchairAPI` object                                                       |\n| `crypto.getPrice(crypto=\"bitcoin\", convertTo=\"usd\")` | `crypto.getPrice(CRYPTO, CONVERTTO)` | Returns the price of `CRYPTO` in `CONVERTTO`. `CONVERTTO` can be `\"bitcoin\"`, `\"btc\"`, or `\"usd\"` |\n| `crypto.getStats(crypto=\"bitcoin\")`                  | `crypto.getStats(CRYPTO)`            | Returns all data on `CRYPTO` in JSON                                                              |\n| `crypto.getOther(url)`                               | `crypto.getOther(URL)`               | Returns JSON data from the specified Blockchair API link.                                         |\n| `crypto.setAPIKey(key)`                              | `crypto.setAPIKey(KEY)`              | Sets `KEY` as the key to be used in all queries.                                                  |\n\n## Implementation Details\n\nThis information is mostly for those who would like to contribute to WebScript but are not sure about how the underlying code works. It assumes a basic understanding of how programming languages are made in general. There are some comments throughout WebScript's code to help you to understand it if you do decide to contribute.\n\nWebScript recognises the following tokens:\n\n( ) { } [ ] . , : | ! \u0026\u0026 == !=== \u003e \u003e= \u003c \u003c= + - \\* \\ `EOF` `Keyword` `Identifier` `String` `Number`\n\nWebScript recognises the following as keywords:\n\nprepare, as, type, prep, has, func, needs, return, loop, through, while, if, elif, else\n\nWebScript's AST contains the following nodes:\n\nLiteral, Array, Var, Binary, Func, Return, For, While, Conditional, Set, Struct, Instance, Call, Get, Unary\n\n\u003c!--\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n#### Arcade Reviewers\n_Previous scrapbook post: This project started off with the Easel tutorial, before I grew it into it's own language. The majority of the lexer, parser, and interpreter were made using the Easel tutorial, with some differences in implementation, formatting, comments, and the language's syntax. I have since then grown the Standard Library to make WebScript about the web, added a test file, added shell and powershell files to run WebScript, added quick-install shell files, and created all of the above documentation. I started this project with almost no knowledge of JavaScript or how to make a programming language, so it has taken me a while longer to implement this than it probably should have. I used no AI in the process._\n\n_Current scrapbook post:_ All of the changes made in the latest version of WebScript (v0.2.0) were completely original. I did not use any AI.\n\n**Thanks for reviewing my project!**!--\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcragglesg%2Fwebscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcragglesg%2Fwebscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcragglesg%2Fwebscript/lists"}