From 1fed4c32e2b03e6a9eba586f840c7f90cdff90b8 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 25 Aug 2023 18:44:11 +0700 Subject: [PATCH] restructure functions --- extension/script.js | 290 ++++++++++++++++++++++---------------------- 1 file changed, 145 insertions(+), 145 deletions(-) diff --git a/extension/script.js b/extension/script.js index 7c53f1e..791db8b 100644 --- a/extension/script.js +++ b/extension/script.js @@ -4,32 +4,6 @@ content script running on youtube.com 'use strict'; -let browserType = getBrowser(); - -// boilerplate to dedect browser type api -function getBrowser() { - if (typeof chrome !== 'undefined') { - if (typeof browser !== 'undefined') { - console.log('detected firefox'); - return browser; - } else { - console.log('detected chrome'); - return chrome; - } - } else { - console.log('failed to dedect browser'); - throw 'browser detection error'; - } -} - -async function sendMessage(message) { - let { success, value } = await browserType.runtime.sendMessage(message); - if (!success) { - throw value; - } - return value; -} - const downloadIcon = `