aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/options.js3
-rw-r--r--ext/bg/js/search-frontend.js51
-rw-r--r--ext/bg/js/settings.js2
-rw-r--r--ext/bg/search.html1
-rw-r--r--ext/bg/settings.html4
5 files changed, 60 insertions, 1 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 2197c72c..1b2d5e1a 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -220,7 +220,8 @@ function optionsSetDefaults(options) {
length: 10,
modifier: 'shift',
deepDomScan: false,
- popupNestingMaxDepth: 0
+ popupNestingMaxDepth: 0,
+ enableOnSearchPage: true
},
dictionaries: {},
diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js
new file mode 100644
index 00000000..77aa4052
--- /dev/null
+++ b/ext/bg/js/search-frontend.js
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 Alex Yatskov <alex@foosoft.net>
+ * Author: Alex Yatskov <alex@foosoft.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+async function searchFrontendSetup() {
+ const options = await apiOptionsGet();
+ if (!options.scanning.enableOnSearchPage) { return; }
+
+ const scriptSrcs = [
+ '/fg/js/api.js',
+ '/fg/js/frontend-api-receiver.js',
+ '/fg/js/popup.js',
+ '/fg/js/popup-proxy-host.js',
+ '/fg/js/util.js',
+ '/fg/js/frontend.js'
+ ];
+ for (const src of scriptSrcs) {
+ const script = document.createElement('script');
+ script.async = false;
+ script.src = src;
+ document.body.appendChild(script);
+ }
+
+ const styleSrcs = [
+ '/fg/css/client.css'
+ ];
+ for (const src of styleSrcs) {
+ const style = document.createElement('link');
+ style.rel = 'stylesheet';
+ style.type = 'text/css';
+ style.href = src;
+ document.head.appendChild(style);
+ }
+}
+
+searchFrontendSetup();
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js
index de1616f3..5472c7bd 100644
--- a/ext/bg/js/settings.js
+++ b/ext/bg/js/settings.js
@@ -48,6 +48,7 @@ async function formRead() {
optionsNew.scanning.alphanumeric = $('#search-alphanumeric').prop('checked');
optionsNew.scanning.autoHideResults = $('#auto-hide-results').prop('checked');
optionsNew.scanning.deepDomScan = $('#deep-dom-scan').prop('checked');
+ optionsNew.scanning.enableOnSearchPage = $('#enable-scanning-on-search-page').prop('checked');
optionsNew.scanning.delay = parseInt($('#scan-delay').val(), 10);
optionsNew.scanning.length = parseInt($('#scan-length').val(), 10);
optionsNew.scanning.modifier = $('#scan-modifier-key').val();
@@ -190,6 +191,7 @@ async function onReady() {
$('#search-alphanumeric').prop('checked', options.scanning.alphanumeric);
$('#auto-hide-results').prop('checked', options.scanning.autoHideResults);
$('#deep-dom-scan').prop('checked', options.scanning.deepDomScan);
+ $('#enable-scanning-on-search-page').prop('checked', options.scanning.enableOnSearchPage);
$('#scan-delay').val(options.scanning.delay);
$('#scan-length').val(options.scanning.length);
$('#scan-modifier-key').val(options.scanning.modifier);
diff --git a/ext/bg/search.html b/ext/bg/search.html
index 05c0daab..38c5a4e9 100644
--- a/ext/bg/search.html
+++ b/ext/bg/search.html
@@ -51,5 +51,6 @@
<script src="/mixed/js/japanese.js"></script>
<script src="/bg/js/search.js"></script>
+ <script src="/bg/js/search-frontend.js"></script>
</body>
</html>
diff --git a/ext/bg/settings.html b/ext/bg/settings.html
index a0d08ec5..0005efa6 100644
--- a/ext/bg/settings.html
+++ b/ext/bg/settings.html
@@ -192,6 +192,10 @@
<label><input type="checkbox" id="auto-hide-results"> Automatically hide results</label>
</div>
+ <div class="checkbox">
+ <label><input type="checkbox" id="enable-scanning-on-search-page"> Enable scanning on search page</label>
+ </div>
+
<div class="checkbox options-advanced">
<label><input type="checkbox" id="deep-dom-scan"> Deep DOM scan</label>
</div>