Extract logic to add buttons to the bulk actions bar

In the future, we will want to add many buttons to the bulk actions bar
in thread lists. This CL prepares for that by moving the logic which
detects whether the button has already been inserted into the bar to a
common file, so it can be reused by features other than the "batch lock"
feature.

Bug: twpowertools:74
Change-Id: Ic98cb68e5a8d0ca97e24578050b53cff6fdde41c
diff --git a/src/contentScripts/communityConsole/utils/common.js b/src/contentScripts/communityConsole/utils/common.js
index ac4db4e..2e33f99 100644
--- a/src/contentScripts/communityConsole/utils/common.js
+++ b/src/contentScripts/communityConsole/utils/common.js
@@ -61,6 +61,17 @@
   return clone;
 }
 
+// Returns true if |node| is the "mark as read/unread" button, the parent of the
+// parent of |node| is the actions bar of the thread list, and the button with
+// debugid |debugid| is NOT part of the actions bar.
+export function shouldAddBtnToActionBar(debugid, node) {
+  return node?.tagName == 'MATERIAL-BUTTON' &&
+      (node.getAttribute?.('debugid') == 'mark-read-button' ||
+       node.getAttribute?.('debugid') == 'mark-unread-button') &&
+      node.parentNode?.querySelector('[debugid="' + debugid + '"]') === null &&
+      node.parentNode?.parentNode?.tagName == 'EC-BULK-ACTIONS';
+}
+
 // Returns the display language set by the user.
 export function getDisplayLanguage() {
   var startup =