Browse Source

proof-of-concept

Brennen Bearnes 7 years ago
commit
878b61230a
7 changed files with 47 additions and 0 deletions
  1. BIN
      icon.png
  2. BIN
      icon128.png
  3. BIN
      icon16.png
  4. BIN
      icon48.png
  5. 18
    0
      manifest.json
  6. 11
    0
      search.css
  7. 18
    0
      search.js

BIN
icon.png View File


BIN
icon128.png View File


BIN
icon16.png View File


BIN
icon48.png View File


+ 18
- 0
manifest.json View File

@@ -0,0 +1,18 @@
1
+{
2
+  "name": "slashfind",
3
+  "version": "1.0",
4
+  "description": "Find in page with the slash key.",
5
+  "icons": {
6
+    "16": "icon16.png",
7
+    "48": "icon48.png",
8
+    "128": "icon128.png"
9
+  },
10
+  "permissions": ["tabs"],
11
+  "content_scripts": [
12
+    {
13
+      "matches": ["<all_urls>"],
14
+      "css": ["search.css"],
15
+      "js": ["search.js"]
16
+    }
17
+  ]
18
+}

+ 11
- 0
search.css View File

@@ -0,0 +1,11 @@
1
+/*
2
+TODO: dynamically change this for the window.find() result maybe?
3
+::selection {
4
+  background:#f094b7;
5
+  color:#555;
6
+}
7
+::-webkit-selection {
8
+  background:#f094b7;
9
+  color:#555;
10
+}
11
+*/

+ 18
- 0
search.js View File

@@ -0,0 +1,18 @@
1
+window.addEventListener('keypress', function (event) {
2
+  // console.log(event);
3
+
4
+  // are we currently in some kind of text input?  skip it.
5
+  if (event.target.nodeName == 'TEXTAREA'
6
+      || event.target.nodeName == 'INPUT'
7
+      || event.target.nodeName == 'SELECT'
8
+      || event.target.nodeName == 'OPTION')
9
+  {
10
+    return;
11
+  }
12
+
13
+  // slash
14
+  if (47 == event.keyCode) {
15
+    var string = prompt('search:', window.getSelection());
16
+    window.find(string);
17
+  }
18
+});

Loading…
Cancel
Save