Add: Code plugin snippet

This commit is contained in:
surunzi
2018-01-09 18:44:21 +08:00
parent 19ee292719
commit 66d62175ce
3 changed files with 15 additions and 3 deletions

View File

@@ -111,6 +111,7 @@ It is possible to enhance Eruda with more features by writing plugins. Check sou
* [eruda-features](https://github.com/liriliri/eruda-features): Browser feature detections.
* [eruda-timing](https://github.com/liriliri/eruda-timing): Show performance and resource timing.
* [eruda-memory](https://github.com/liriliri/eruda-memory): Display page memory info.
* [eruda-code](https://github.com/liriliri/eruda-code): Run JavaScript code.
When writing plugins, you can use utilities exposed by Eruda, see [docs](doc/UTIL_API.md) here.

View File

@@ -361,9 +361,11 @@ let evalJs = jsInput =>
{
let ret;
try {
try
{
ret = eval.call(window, `(${jsInput})`);
} catch (e) {
} catch (e)
{
ret = eval.call(window, jsInput);
}

View File

@@ -96,6 +96,14 @@ export default [
},
desc: 'Display memory'
},
{
name: 'Load Code Plugin',
fn()
{
loadPlugin('code');
},
desc: 'Edit and Run JavaScript'
},
{
name: 'Restore Settings',
fn()
@@ -193,5 +201,6 @@ let pluginVersion = {
fps: '1.0.2',
features: '1.0.2',
timing: '1.0.1',
memory: '1.0.1'
memory: '1.0.1',
code: '1.0.0'
};