diff options
author | Wojtek Kosior <koszko@koszko.org> | 2021-09-10 16:50:56 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2021-09-10 16:50:56 +0200 |
commit | 5c75d7446187a01409eff1a1e5946f66267f61fb (patch) | |
tree | bbb6b86d0f404fce68b8f70cafacb8b4eaee35be | |
parent | 72cbfa74f7f30fdf60fc6ad73182ed1cca3d3712 (diff) | |
download | browser-extension-5c75d7446187a01409eff1a1e5946f66267f61fb.tar.gz browser-extension-5c75d7446187a01409eff1a1e5946f66267f61fb.zip |
Make it impossible to check "Allow native scripts" for pages with payload.
-rw-r--r-- | background/page_actions_server.js | 14 | ||||
-rw-r--r-- | html/options.html | 23 | ||||
-rw-r--r-- | html/options_main.js | 3 |
3 files changed, 33 insertions, 7 deletions
diff --git a/background/page_actions_server.js b/background/page_actions_server.js index b0db5f5..e21ca6e 100644 --- a/background/page_actions_server.js +++ b/background/page_actions_server.js @@ -25,15 +25,19 @@ let policy_observable; function send_actions(url, port) { - let [pattern, settings] = query_best(storage, url); - if (!settings) - settings = {allow: policy_observable && policy_observable.value}; + const [pattern, queried_settings] = query_best(storage, url); + + const settings = {allow: policy_observable && policy_observable.value}; + Object.assign(settings, queried_settings); + if (settings.components) + settings.allow = false; + const repos = storage.get_all(TYPE_PREFIX.REPO); port.postMessage(["settings", [pattern, settings, repos]]); - let components = settings.components; - let processed_bags = new Set(); + const components = settings.components; + const processed_bags = new Set(); if (components !== undefined) send_scripts([components], port, processed_bags); diff --git a/html/options.html b/html/options.html index f2a75e1..01b1061 100644 --- a/html/options.html +++ b/html/options.html @@ -152,6 +152,22 @@ min-width: 70vw; resize: none; } + + .form_disabled>* { + opacity: 0.5; + pointer-events: none; + } + + .form_disabled_msg { + display: none; + font-style: italic; + } + + .form_disabled .form_disabled_msg { + opacity: initial; + pointer-events: initial; + display: initial; + } </style> </head> <body> @@ -226,15 +242,18 @@ <label for="page_url_field">URL: </label> <input id="page_url_field"></input> <label>Payload: </label> - <span> + <span class="nowrap"> <span id="page_payload"></span> <button id="select_page_components_but"> Choose payload </button> </span> - <div> + <div id="allow_native_scripts_container" class="nowrap"> <input id="page_allow_chbx" type="checkbox" style="display: inline;"></input> <label for="page_allow_chbx">Allow native scripts</label> + <span class="form_disabled_msg"> + (only possible when no payload is used) + </span> </div> <div> <button id="save_page_but" type="button"> Save </button> diff --git a/html/options_main.js b/html/options_main.js index 2f4f154..27ab0ec 100644 --- a/html/options_main.js +++ b/html/options_main.js @@ -157,6 +157,7 @@ function work_repo_li_data(ul) return [ul.work_name_input.value, {}]; } +const allow_native_scripts_container = by_id("allow_native_scripts_container"); const page_payload_span = by_id("page_payload"); function set_page_components(components) @@ -164,12 +165,14 @@ function set_page_components(components) if (components === undefined) { page_payload_span.setAttribute("data-payload", "no"); page_payload_span.textContent = "(None)"; + allow_native_scripts_container.classList.remove("form_disabled"); } else { page_payload_span.setAttribute("data-payload", "yes"); let [prefix, name] = components; page_payload_span.setAttribute("data-prefix", prefix); page_payload_span.setAttribute("data-name", name); page_payload_span.textContent = nice_name(prefix, name); + allow_native_scripts_container.classList.add("form_disabled"); } } |