feat(extension): set user agent on requests
This commit is contained in:
parent
e626ff5eae
commit
d2811c55df
3 changed files with 6 additions and 4 deletions
|
@ -51,6 +51,7 @@ function interceptSubmit(details) {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
|
'user-agent': 'Mozilla/5.0 (compatible) aci-extension/1.0 (+https://git.ashhhleyyy.dev/ash/aci)',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
code: activity.code,
|
code: activity.code,
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
this.SERVER_URL = 'https://aci-api.ashhhleyyy.dev';
|
this.SERVER_URL = 'https://aci-api.ashhhleyyy.dev';
|
||||||
//this.SERVER_URL = 'http://localhost:8000';
|
//this.SERVER_URL = 'http://localhost:8000';
|
||||||
|
this.USER_AGENT = 'Mozilla/5.0 (compatible) aci-extension/1.0 (+https://git.ashhhleyyy.dev/ash/aci)'
|
||||||
|
|
|
@ -113,7 +113,7 @@ chrome.storage.sync.get([
|
||||||
if (window.location.hash.length >= 2) {
|
if (window.location.hash.length >= 2) {
|
||||||
const query = window.location.hash.substring(1);
|
const query = window.location.hash.substring(1);
|
||||||
const queryParams = new URLSearchParams(query);
|
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}`);
|
message(`Something went wrong: ${e}`);
|
||||||
console.error(e);
|
console.error(e);
|
||||||
});
|
});
|
||||||
|
@ -125,7 +125,7 @@ chrome.storage.sync.get([
|
||||||
const activity = await res.json();
|
const activity = await res.json();
|
||||||
|
|
||||||
if (config.enable_reject) {
|
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}`);
|
message(`Something went wrong: ${e}`);
|
||||||
console.error(e);
|
console.error(e);
|
||||||
});
|
});
|
||||||
|
@ -138,7 +138,7 @@ chrome.storage.sync.get([
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.enable_shrine) {
|
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}`);
|
message(`Something went wrong: ${e}`);
|
||||||
console.error(e);
|
console.error(e);
|
||||||
});
|
});
|
||||||
|
@ -162,7 +162,7 @@ chrome.storage.sync.get([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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}`);
|
message(`Something went wrong: ${e}`);
|
||||||
console.error(e);
|
console.error(e);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue