From 9eac50ea05ae48e77c1bb0ef7b42d9662094cbf8 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 5 Sep 2017 12:34:52 -0700 Subject: add sandbox stub --- ext/bg/background.html | 2 ++ ext/manifest.json | 5 ++++- ext/sb/js/sandbox.js | 30 ++++++++++++++++++++++++++++++ ext/sb/sandbox.html | 10 ++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 ext/sb/js/sandbox.js create mode 100644 ext/sb/sandbox.html diff --git a/ext/bg/background.html b/ext/bg/background.html index 97b20f46..151d7e81 100644 --- a/ext/bg/background.html +++ b/ext/bg/background.html @@ -24,5 +24,7 @@ + + diff --git a/ext/manifest.json b/ext/manifest.json index 2a5f1910..e95cc496 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Yomichan", - "version": "1.3.4", + "version": "1.3.5", "description": "Japanese dictionary with Anki integration", "icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"}, @@ -55,5 +55,8 @@ "strict_min_version": "52.0", "update_url": "https://foosoft.net/projects/yomichan/dl/updates.json" } + }, + "sandbox": { + "pages": ["sb/sandbox.html"] } } diff --git a/ext/sb/js/sandbox.js b/ext/sb/js/sandbox.js new file mode 100644 index 00000000..76b7b511 --- /dev/null +++ b/ext/sb/js/sandbox.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017 Alex Yatskov + * Author: Alex Yatskov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +window.addEventListener('message', event => { + if (event.data.command === 'render') { + const template = Handlebars.compile(event.data.template || ''); + const result = template(event.data.context || {}); + event.source.postMessage({result, sequence: event.data.sequence}); + } +}); diff --git a/ext/sb/sandbox.html b/ext/sb/sandbox.html new file mode 100644 index 00000000..b9d33cf6 --- /dev/null +++ b/ext/sb/sandbox.html @@ -0,0 +1,10 @@ + + + + + + + + + + -- cgit v1.2.3