aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2015-05-24 17:09:51 -0400
committerTeddy Wing2015-05-24 17:09:51 -0400
commit1f8c77706f219f4e91f26eb28de63f64961727ce (patch)
tree55d982a3afc8fadc6c725b4b8ef694bb13c4a901
parent5a9aab5e4ebb71770c67fa266ef651b2e8dcbbd6 (diff)
downloadPeniquitous-1f8c77706f219f4e91f26eb28de63f64961727ce.tar.bz2
Inject peniquitous.js into the page context
Instead of handling the keyboard events in the content script, inject a script onto the page that does the key listening and simulating. This allows the simulation of up & down arrow key presses to actually trigger the proper page event listeners and allow our custom code to do the right thing instead of firing a key event in the Chrome extension's isolated environment and not having anything happening because no listeners are attached in the isolated environment. Also inject the `KeyEvent` object from Mousetrap so we can use it's key simulation feature. Will likely want to extract that into our own custom code so we're not including a whole script that we only use 20% of or so.
-rw-r--r--main.js13
-rw-r--r--manifest.json9
2 files changed, 20 insertions, 2 deletions
diff --git a/main.js b/main.js
new file mode 100644
index 0000000..204717e
--- /dev/null
+++ b/main.js
@@ -0,0 +1,13 @@
+(function() {
+ [
+ 'lib/mousetrap/tests/libs/key-event.js',
+ 'peniquitous.js'
+ ].forEach(function(file) {
+ var s = document.createElement('script');
+ s.src = chrome.extension.getURL(file);
+ s.onload = function() {
+ this.parentNode.removeChild(this);
+ };
+ document.documentElement.appendChild(s);
+ });
+})();
diff --git a/manifest.json b/manifest.json
index 68f6489..1a54de4 100644
--- a/manifest.json
+++ b/manifest.json
@@ -7,6 +7,11 @@
"content_scripts": [{
"matches": ["<all_urls>"],
- "js": ["lib/mousetrap/tests/libs/key-event.js", "peniquitous.js"]
- }]
+ "js": ["main.js"]
+ }],
+
+ "web_accessible_resources": [
+ "lib/mousetrap/tests/libs/key-event.js",
+ "peniquitous.js"
+ ]
}