From d2811c55dfbdfbf5c16ae267bc561e6ce731a198 Mon Sep 17 00:00:00 2001 From: Ashhhleyyy Date: Tue, 12 Mar 2024 09:55:15 +0000 Subject: [PATCH] feat(extension): set user agent on requests --- extension/src/background.js | 1 + extension/src/config.js | 1 + extension/src/popup.js | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/extension/src/background.js b/extension/src/background.js index dc92504..ad908ef 100644 --- a/extension/src/background.js +++ b/extension/src/background.js @@ -51,6 +51,7 @@ function interceptSubmit(details) { method: 'POST', headers: { 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (compatible) aci-extension/1.0 (+https://git.ashhhleyyy.dev/ash/aci)', }, body: JSON.stringify({ code: activity.code, diff --git a/extension/src/config.js b/extension/src/config.js index 54469e2..53cc59a 100644 --- a/extension/src/config.js +++ b/extension/src/config.js @@ -1,2 +1,3 @@ this.SERVER_URL = 'https://aci-api.ashhhleyyy.dev'; //this.SERVER_URL = 'http://localhost:8000'; +this.USER_AGENT = 'Mozilla/5.0 (compatible) aci-extension/1.0 (+https://git.ashhhleyyy.dev/ash/aci)' diff --git a/extension/src/popup.js b/extension/src/popup.js index a163612..91340bc 100644 --- a/extension/src/popup.js +++ b/extension/src/popup.js @@ -113,7 +113,7 @@ chrome.storage.sync.get([ if (window.location.hash.length >= 2) { const query = window.location.hash.substring(1); const queryParams = new URLSearchParams(query); - const res = await fetch(SERVER_URL + '/api/codes/query?' + query).catch((e) => { + const res = await fetch(SERVER_URL + '/api/codes/query?' + query, { headers: { 'user-agent': USER_AGENT } }).catch((e) => { message(`Something went wrong: ${e}`); console.error(e); }); @@ -125,7 +125,7 @@ chrome.storage.sync.get([ const activity = await res.json(); if (config.enable_reject) { - const rejectRes = await fetch(SERVER_URL + '/3p-proxy/reject?' + query).catch((e) => { + const rejectRes = await fetch(SERVER_URL + '/3p-proxy/reject?' + query, { headers: { 'user-agent': USER_AGENT } }).catch((e) => { message(`Something went wrong: ${e}`); console.error(e); }); @@ -138,7 +138,7 @@ chrome.storage.sync.get([ } if (config.enable_shrine) { - const shrineRes = await fetch(SERVER_URL + '/3p-proxy/shrine-checkout?' + query).catch((e) => { + const shrineRes = await fetch(SERVER_URL + '/3p-proxy/shrine-checkout?' + query, { headers: { 'user-agent': USER_AGENT } }).catch((e) => { message(`Something went wrong: ${e}`); console.error(e); }); @@ -162,7 +162,7 @@ chrome.storage.sync.get([ } } } else { - const res = await fetch(SERVER_URL + '/api/codes').catch((e) => { + const res = await fetch(SERVER_URL + '/api/codes', { headers: { 'user-agent': USER_AGENT } }).catch((e) => { message(`Something went wrong: ${e}`); console.error(e); });