diff options
Diffstat (limited to 'html/display-panel.js')
-rw-r--r-- | html/display-panel.js | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/html/display-panel.js b/html/display-panel.js index 7d801c9..c078850 100644 --- a/html/display-panel.js +++ b/html/display-panel.js @@ -1,5 +1,7 @@ /** - * Hachette display panel logic + * This file is part of Haketilo. + * + * Function: Popup logic. * * Copyright (C) 2021 Wojtek Kosior * Redistribution terms are gathered in the `copyright' file. @@ -21,7 +23,6 @@ * IMPORT TYPE_PREFIX * IMPORT nice_name * IMPORT open_in_settings - * IMPORT url_matches * IMPORT each_url_pattern * IMPORT by_id * IMPORT clone_template @@ -114,36 +115,21 @@ function add_pattern_to_list(pattern) return template; } -function ensure_pattern_exists(pattern) -{ - let entry_object = known_patterns.get(pattern); - /* - * As long as pattern computation works well, we should never get into this - * conditional block. This is just a safety measure. To be removed as part - * of a bigger rework when we start taking iframes into account. - */ - if (entry_object === undefined) { - console.log(`unknown pattern: ${pattern}`); - entry_object = add_pattern_to_list(pattern); - } - - return entry_object; -} - function style_possible_pattern_entry(pattern, exists_in_settings) { const [text, class_action] = exists_in_settings ? ["Edit", "add"] : ["Add", "remove"]; - const entry_object = ensure_pattern_exists(pattern); + const entry_object = known_patterns.get(pattern); - entry_object.button.textContent = `${text} setting`; - entry_object.entry.classList[class_action]("matched_pattern"); + if (entry_object) { + entry_object.button.textContent = `${text} setting`; + entry_object.entry.classList[class_action]("matched_pattern"); + } } function handle_page_change(change) { - if (url_matches(tab_url, change.item)) - style_possible_pattern_entry(change.item, change.new_val !== undefined); + style_possible_pattern_entry(change.item, change.new_val !== undefined); } function populate_possible_patterns_list(url) @@ -276,8 +262,8 @@ function handle_activity_report(message) template.script_contents.textContent = data; container_for_injected.appendChild(template.div); } - if (type === "content_type") { - if (!/html/.test(data)) + if (type === "is_html") { + if (!data) content_type_cell.classList.remove("hide"); } if (type === "repo_query_action") { |