From ac012b26b37f6c01a80c1faa98fbe43913e47b6e Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Thu, 24 Mar 2016 20:30:18 -0700 Subject: [PATCH] File reorg and cleanup --- ext/{util.js => api.js} | 0 ext/background.html | 2 +- ext/jp/{init.js => api.js} | 26 ++++++++++++-------------- ext/manifest.json | 5 ++--- 4 files changed, 15 insertions(+), 18 deletions(-) rename ext/{util.js => api.js} (100%) rename ext/jp/{init.js => api.js} (73%) diff --git a/ext/util.js b/ext/api.js similarity index 100% rename from ext/util.js rename to ext/api.js diff --git a/ext/background.html b/ext/background.html index f0d06216..09a21779 100644 --- a/ext/background.html +++ b/ext/background.html @@ -5,6 +5,6 @@ - + diff --git a/ext/jp/init.js b/ext/jp/api.js similarity index 73% rename from ext/jp/init.js rename to ext/jp/api.js index 56ec8b34..3f15056a 100644 --- a/ext/jp/init.js +++ b/ext/jp/api.js @@ -17,20 +17,6 @@ */ -function onInit() { - const test = trans.findTerm('食べられない'); - chrome.runtime.onMessage.addListener(onMessage); -} - -const res = { - rules: 'jp/data/rules.json', - edict: 'jp/data/edict.json', - enamdict: 'jp/data/enamdict.json', - kanjidic: 'jp/data/kanjidic.json' -}; - -window.trans = new Translator(res, onInit); - function onMessage(request, sender, callback) { switch (request.action.toLowerCase()) { case 'define': @@ -39,3 +25,15 @@ function onMessage(request, sender, callback) { } } +(() => { + const res = { + rules: 'jp/data/rules.json', + edict: 'jp/data/edict.json', + enamdict: 'jp/data/enamdict.json', + kanjidic: 'jp/data/kanjidic.json' + }; + + window.trans = new Translator(res, function() { + chrome.runtime.onMessage.addListener(onMessage); + }); +})(); diff --git a/ext/manifest.json b/ext/manifest.json index c46e20af..a225faeb 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -8,8 +8,7 @@ "background": {"page": "background.html"}, "content_scripts": [{ - "matches": ["http://*/*", "https://*/*"], - "js": ["content.js", "util.js"], - "run_at": "document_end" + "matches": ["*://*/*"], + "js": ["content.js", "api.js"] }] }