From 9ab16dcd34c5c3034a1bbb613ac8d9aa8f779c90 Mon Sep 17 00:00:00 2001 From: Matthew Jorgensen Date: Sun, 6 Feb 2022 12:39:38 -0600 Subject: [PATCH] Use arrays for status/action-bar selectors Fixes #8: No icon in replies on a single status page --- js/mastodon/mastopinner.js | 19 ++++++++++++++++--- js/mastodon/mastopinner_ui.js | 6 +++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/js/mastodon/mastopinner.js b/js/mastodon/mastopinner.js index e544566..c353a63 100644 --- a/js/mastodon/mastopinner.js +++ b/js/mastodon/mastopinner.js @@ -1,4 +1,7 @@ -const STATUS_SELECTOR = '.item-list .status'; +const STATUS_SELECTORS = [ + '.item-list .status', + '.scrollable .status' +]; class MastoPinner { constructor() { @@ -17,7 +20,12 @@ class MastoPinner { } // inject the initially visible statuses - let statuses = document.querySelectorAll(STATUS_SELECTOR); + let statuses = []; + STATUS_SELECTORS.forEach((selector) => { + document.querySelectorAll(selector).forEach((s) => { + statuses.push(s); + }); + }); if (statuses.length > 0) { this._inject(); } @@ -30,7 +38,12 @@ class MastoPinner { } async _inject() { - let statuses = document.querySelectorAll(STATUS_SELECTOR); + let statuses = []; + STATUS_SELECTORS.forEach((selector) => { + document.querySelectorAll(selector).forEach((s) => { + statuses.push(s); + }); + }); if (statuses.length == 0) { console.warn(`MastoPinner: couldn't inject the UI: no statuses found.`); return; diff --git a/js/mastodon/mastopinner_ui.js b/js/mastodon/mastopinner_ui.js index a82b87b..d2aa9d7 100644 --- a/js/mastodon/mastopinner_ui.js +++ b/js/mastodon/mastopinner_ui.js @@ -1,3 +1,7 @@ +const ACTION_BAR_SELECTORS = [ + 'div.status__action-bar' +]; + class MastoPinnerUI { constructor(status, { send }) { this.status = status; @@ -6,7 +10,7 @@ class MastoPinnerUI { } render() { - this.actionBar = this.status.querySelector('div.status__action-bar'); + this.actionBar = this.status.querySelector(ACTION_BAR_SELECTORS); // define node to insert let nodeHtml = `