aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/popup-nested.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-08-17 19:32:58 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-02 19:32:08 -0400
commit1a9348ec27b903af47511da11306f884a82cf353 (patch)
treeba890d2a69b83281d34209d8841a6be83d713d23 /ext/fg/js/popup-nested.js
parent5c4614f585648c2b835efc1d369e78918bc4f5ff (diff)
Add option for maximum nested popup depth
Diffstat (limited to 'ext/fg/js/popup-nested.js')
-rw-r--r--ext/fg/js/popup-nested.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js
new file mode 100644
index 00000000..7df4e4e2
--- /dev/null
+++ b/ext/fg/js/popup-nested.js
@@ -0,0 +1,48 @@
+/*
+ * 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 popupNestedSetup() {
+ const options = await apiOptionsGet();
+ const popupNestingMaxDepth = options.scanning.popupNestingMaxDepth;
+
+ let depth = null;
+ const match = /[&?]depth=([^&]*?)(?:&|$)/.exec(location.href);
+ if (match !== null) {
+ depth = parseInt(match[1], 10);
+ }
+
+ if (!(typeof popupNestingMaxDepth === 'number' && typeof depth === 'number' && depth < popupNestingMaxDepth)) {
+ return;
+ }
+
+ const scriptSrcs = [
+ '/fg/js/frontend-api-sender.js',
+ '/fg/js/popup.js',
+ '/fg/js/popup-proxy.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);
+ }
+}
+
+popupNestedSetup();