diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-03-08 18:15:23 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-03-10 11:43:51 +0100 |
commit | 003876d507112ebe2575086514d5a388f78dedd9 (patch) | |
tree | 58cc0e5f119df559377dbff830d140110eca35a0 /html | |
parent | 093ec2a52697afdda610dde1302a59183719ac0f (diff) | |
download | browser-extension-003876d507112ebe2575086514d5a388f78dedd9.tar.gz browser-extension-003876d507112ebe2575086514d5a388f78dedd9.zip |
present appropriate error message when using popup in Private Browsing mode
Diffstat (limited to 'html')
-rw-r--r-- | html/popup.js | 6 | ||||
-rw-r--r-- | html/repo_query.html | 11 | ||||
-rw-r--r-- | html/repo_query.js | 22 |
3 files changed, 31 insertions, 8 deletions
diff --git a/html/popup.js b/html/popup.js index 5a5db6c..52df3ae 100644 --- a/html/popup.js +++ b/html/popup.js @@ -132,8 +132,8 @@ function repo_query_showing(show) { by_id(`${id}_container`).classList[["add", "remove"][show ^ i]]("hide"); } -function prepare_repo_query_view(tab_id, page_info) { - const repo_query_view = new RepoQueryView(tab_id, +function prepare_repo_query_view(tab, page_info) { + const repo_query_view = new RepoQueryView(tab, () => repo_query_showing(true), () => repo_query_showing(false)); by_id("repo_query_container").prepend(repo_query_view.main_div); @@ -163,7 +163,7 @@ async function main() { if (page_info) { show_page_info(page_info); if (!page_info.privileged) - prepare_repo_query_view(tab_id, page_info); + prepare_repo_query_view(tab, page_info); } else { by_id("loading_info").innerText = "Page info not avaialable. Try reloading the page."; diff --git a/html/repo_query.html b/html/repo_query.html index 67158cc..8692c3b 100644 --- a/html/repo_query.html +++ b/html/repo_query.html @@ -105,9 +105,16 @@ } </style> <template> - <div id="repo_query" data-template="main_div" class="repo_query_main_div"> + <span id="repo_query_private_mode_error", data-template="main_span"> + Due to bug <a href="https://hydrillabugs.koszko.org/issues/115">#115</a> it + is currently impossible to install scripts through the popup when in Private + Browsing mode. You can instead perform the installation after navigating to + the website in a non-private window. Scripts you install there shall affect + websites browsed in Private Mode as well. + </span> + <div id="repo_query" data-template="main_div"> <div data-template="repos_list_container"> - <div class="repo_query_top_text"> + <div class="repo_query_top_text", data-template="top_text"> Browsing custom resources for: <span data-template="url_span" class="repo_queried_url"></span> </div> diff --git a/html/repo_query.js b/html/repo_query.js index 7cfd6fe..601a0aa 100644 --- a/html/repo_query.js +++ b/html/repo_query.js @@ -160,11 +160,20 @@ function RepoEntry(query_view, repo_url) { const container_ids = ["repos_list_container", "install_view_container"]; -function RepoQueryView(tab_id, on_view_show, on_view_hide) { +function RepoQueryView(tab, on_view_show, on_view_hide) { Showable.call(this, on_view_show, on_view_hide); Object.assign(this, clone_template("repo_query")); - this.tab_id = tab_id; + this.tab_id = tab.id; +#IF MOZILLA + this.incognito = tab.incognito; + if (this.incognito) { + [...this.top_text.childNodes].forEach(n => n.remove()); + this.top_text.append( + clone_template("repo_query_private_mode_error").main_span + ); + } +#ENDIF const show_container = name => { for (const cid of container_ids) { @@ -175,7 +184,7 @@ function RepoQueryView(tab_id, on_view_show, on_view_hide) { } this.install_view = new InstallView( - tab_id, + this.tab_id, () => show_container("install_view_container"), () => show_container("repos_list_container") ); @@ -186,6 +195,13 @@ function RepoQueryView(tab_id, on_view_show, on_view_hide) { if (!show_super()) return; +#IF MOZILLA + if (this.incognito) { + this.repo_entries = []; + return; + } +#ENDIF + this.url = url; this.url_span.innerText = url; |