aboutsummaryrefslogtreecommitdiff
path: root/html/display-panel.js
diff options
context:
space:
mode:
authorjahoti <jahoti@tilde.team>2021-09-21 00:00:00 +0000
committerjahoti <jahoti@tilde.team>2021-09-21 00:00:00 +0000
commit59fb32a341d42c685b5167c3d8b4d7b87c49fd18 (patch)
tree17143cd40a59eb06b4e698d6fd9ca9d02abaf2b9 /html/display-panel.js
parentb1444d9c9ea065d7c97d5809c3ec5259cb01a1da (diff)
parent960363e7dd98a724246320e49c3fbaff9d68d1bd (diff)
downloadbrowser-extension-59fb32a341d42c685b5167c3d8b4d7b87c49fd18.tar.gz
browser-extension-59fb32a341d42c685b5167c3d8b4d7b87c49fd18.zip
Merge branch 'master' into jahoti-update
Diffstat (limited to 'html/display-panel.js')
-rw-r--r--html/display-panel.js36
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") {