A Chrome extension that allows users to evaluate JavaScript code using WebAssembly with Duktape or QuickJS engines. This extension provides a safe and isolated environment to run JavaScript code snippets.
- Evaluate JavaScript code snippets.
- Choose from predefined code examples.
- View the result of the evaluation in the popup.
-
Clone this repository to your local machine:
git clone https://github.com/leizhenpeng/chrome-v3-wasm-eval.git
-
Navigate to the project directory:
cd chrome-v3-wasm-eval
-
Download the required
duktapeEval.js
andquickjsEval.js
files from the wasm-jseval project and place them in the project directory. -
Open Chrome and go to
chrome://extensions/
. -
Enable "Developer mode" by clicking the toggle switch in the top right corner.
-
Click the "Load unpacked" button and select the project directory.
- Click on the extension icon in the Chrome toolbar to open the popup.
- Select a predefined code example from the dropdown menu or enter your own JavaScript code in the textarea.
- Click the "Evaluate" button to execute the code.
- The result of the evaluation will be displayed in the output area.
my-chrome-extension/
│
├── manifest.json # Chrome extension manifest file
├── background.js # Background script
├── popup.html # Popup HTML file
├── popup.js # Popup JavaScript file
├── styles.css # Popup CSS file
├── duktapeEval.js # Duktape eval library (download from wasm-jseval)
├── quickjsEval.js # QuickJS eval library (download from wasm-jseval)
├── README.md # Project readme file
-
简单数学运算
2 + 2
预期结果:
4
-
字符串操作
'Hello, ' + 'World!'
预期结果:
Hello, World!
-
数组操作
[1, 2, 3].map(x => x * 2)
预期结果:
[2, 4, 6]
-
对象属性访问
({a: 1, b: 2}).a
预期结果:
1
-
函数定义和调用
function add(a, b) { return a + b; } add(3, 4)
预期结果:
7
This project is licensed under the MIT License. See the LICENSE file for details.