From c570aff66df2c5e868b9ff55ebb9f6310241a94d Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Fri, 3 Nov 2023 09:00:39 -0700 Subject: [PATCH] Revert "delay buildChannelButton to account for UI refresh on YT" This reverts commit aaa04a43b5eaf14f8763390a2f6065c0ac87d8dc. --- .eslintrc.js | 1 - extension/script.js | 36 +++++++++++++++--------------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ccc033b..72398fc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,7 +6,6 @@ module.exports = { }, env: { browser: true, - es6: true, }, globals: { browser: 'readonly', diff --git a/extension/script.js b/extension/script.js index 72451a5..32bb357 100644 --- a/extension/script.js +++ b/extension/script.js @@ -124,13 +124,13 @@ function isElementVisible(element) { function ensureTALinks() { let channelContainerNodes = getChannelContainers(); + for (let channelContainer of channelContainerNodes) { channelContainer = adjustOwner(channelContainer); if (channelContainer.hasTA) continue; + let channelButton = buildChannelButton(channelContainer); + channelContainer.appendChild(channelButton); channelContainer.hasTA = true; - buildChannelButton(channelContainer).then(channelButton => { - channelContainer.appendChild(channelButton); - }); } let titleContainerNodes = getTitleContainers(); @@ -150,25 +150,19 @@ function adjustOwner(channelContainer) { } function buildChannelButton(channelContainer) { - return new Promise(resolve => { - let buttonDiv; - let channelSubButton; - let spacer; - let channelDownloadButton; + let channelHandle = getChannelHandle(channelContainer); + let buttonDiv = buildChannelButtonDiv(); - // Delayed execution for interface to refresh - setTimeout(() => { - const channelHandle = getChannelHandle(channelContainer); - buttonDiv = buildChannelButtonDiv(); - channelSubButton = buildChannelSubButton(channelHandle); - spacer = buildSpacer(); - channelDownloadButton = buildChannelDownloadButton(); - buttonDiv.appendChild(channelSubButton); - buttonDiv.appendChild(spacer); - buttonDiv.appendChild(channelDownloadButton); - resolve(buttonDiv); - }, 2000); - }); + let channelSubButton = buildChannelSubButton(channelHandle); + buttonDiv.appendChild(channelSubButton); + + let spacer = buildSpacer(); + buttonDiv.appendChild(spacer); + + let channelDownloadButton = buildChannelDownloadButton(); + buttonDiv.appendChild(channelDownloadButton); + + return buttonDiv; } function getChannelHandle(channelContainer) {