feat(extension): set user agent on requests

This commit is contained in:
Ashhhleyyy 2024-03-12 09:55:15 +00:00
parent e626ff5eae
commit d2811c55df
Signed by: ash
GPG key ID: 83B789081A0878FB
3 changed files with 6 additions and 4 deletions

View file

@ -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,

View file

@ -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)'

View file

@ -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);
});