From 67beeca09d8d6c01c7fde733ef7fddb252cf30fd Mon Sep 17 00:00:00 2001 From: Ealhad Date: Tue, 28 Aug 2018 23:19:48 +0200 Subject: [PATCH] Remove video link even if search fail (duh) The bar was just staying there after having been displayed once. --- src/youtube.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/youtube.ts b/src/youtube.ts index 44cb76b..cbcd845 100644 --- a/src/youtube.ts +++ b/src/youtube.ts @@ -28,16 +28,16 @@ function peertubeify(query: string) { browser.runtime.sendMessage({ query }).then(async video => { - removeVideoLink(); - const options = await browser.storage.local.get(); const openInOriginalInstance = _.getOr(true, 'openInOriginalInstance', options); const searchInstance = _.getOr(constants.defaultInstance, 'searchInstance', options); const url = watchURL(openInOriginalInstance ? video.account.host : searchInstance, video.uuid); const link = videoLink(url, video); + + removeVideoLink(); document.querySelector('ytd-app').appendChild(link); - }); + }).catch(removeVideoLink); } const throttledPeertubify = _.throttle(1000, peertubeify); @@ -58,7 +58,7 @@ observer.observe(document.body, { subtree: true, }) -function htmlToElement(html: string) : Element { +function htmlToElement(html: string): Element { const template = document.createElement('template'); template.innerHTML = html.trim(); return template.content.firstElementChild;