From 45bb4e2303c659eff1bb92e495618a28f10d81a4 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Wed, 28 May 2025 15:59:28 +0300 Subject: [PATCH] Fix issue prevent adding urls via Chromium browsers. --- README.md | 10 ++++++++-- src/background.js | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bedd427..a88f4e2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # A YTPTube extension -This extension can be used in `Chrome/Chromium browsers` and `Firefox` to add URLs to [YTPTube](https://github.com/arabcoders/ytptube) instance. +This extension can be used in `Chrome/Chromium browsers` and `Firefox` to add URLs +to [YTPTube](https://github.com/arabcoders/ytptube) instance. ## Screenshots @@ -9,8 +10,13 @@ This extension can be used in `Chrome/Chromium browsers` and `Firefox` to add UR ## Installation from store - Install from [Firefox](https://addons.mozilla.org/en-US/firefox/addon/ytptube-extension/) -- Install from [Chrome/Chromium Browsers](https://chromewebstore.google.com/detail/ytptube-extension/kiepfnpeflemfokokgjiaelddchglfil) +- Install + from [Chrome/Chromium Browsers](https://chromewebstore.google.com/detail/ytptube-extension/kiepfnpeflemfokokgjiaelddchglfil) ## Usage Configure the extension to point to your YTPTube instance in the extension options page. + +## For issues + +To report issues, please use the [GitHub issues page](https://github.com/arabcoders/ytptube/issues) at this repository. \ No newline at end of file diff --git a/src/background.js b/src/background.js index 4677712..e9e95e5 100644 --- a/src/background.js +++ b/src/background.js @@ -70,15 +70,15 @@ const sendRequest = async (path, data) => { const url = new URL(instanceUrl); url.pathname = path; - console.debug(`Sending to '${instanceUrl}'.`, data, headers.length > 0 ? 'with auth header' : 'without auth header'); - - let opts = {method: data.length > 0 ? 'POST' : 'GET', headers: headers}; + let opts = {method: Object.keys(data).length > 0 ? 'POST' : 'GET', headers: headers}; if (data) { opts.headers['Content-Type'] = 'application/json'; opts.body = JSON.stringify(data); } + console.debug(`Sending to '${instanceUrl}'.`, opts, headers.length > 0 ? 'with auth header' : 'without auth header'); + const req = await fetch(url, opts); return {status: req.status, statusText: req.statusText, data: req}; };