mirror of
https://github.com/tubearchivist/browser-extension.git
synced 2024-11-22 19:50:12 +00:00
send cookie to api
This commit is contained in:
parent
5b3b882a30
commit
ff0e8c1185
@ -132,10 +132,25 @@ async function subscribeLink(toSubscribe) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function cookieStr(cookieLines) {
|
||||||
|
|
||||||
|
let cookieString = cookieLines.join("\n");
|
||||||
|
const path = "api/cookie/";
|
||||||
|
let payload = {
|
||||||
|
"cookie": cookieString
|
||||||
|
}
|
||||||
|
let response = await sendData(path, payload, "PUT");
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function buildCookieLine(cookie) {
|
function buildCookieLine(cookie) {
|
||||||
return [
|
return [
|
||||||
cookie.domain,
|
cookie.domain,
|
||||||
cookie.hostOnly.toString().toUpperCase(),
|
"TRUE",
|
||||||
cookie.path,
|
cookie.path,
|
||||||
cookie.httpOnly.toString().toUpperCase(),
|
cookie.httpOnly.toString().toUpperCase(),
|
||||||
cookie.expirationDate,
|
cookie.expirationDate,
|
||||||
@ -165,8 +180,10 @@ async function sendCookies() {
|
|||||||
cookieLines.push(buildCookieLine(cookie));
|
cookieLines.push(buildCookieLine(cookie));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(cookieLines.length);
|
|
||||||
console.log(cookieLines.join("\n"));
|
let response = cookieStr(cookieLines);
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,6 +213,9 @@ function handleMessage(request, sender, sendResponse) {
|
|||||||
} else if (request.cookie) {
|
} else if (request.cookie) {
|
||||||
console.log("backgound: " + JSON.stringify(request));
|
console.log("backgound: " + JSON.stringify(request));
|
||||||
let response = sendCookies();
|
let response = sendCookies();
|
||||||
|
response.then(message => {
|
||||||
|
sendResponse(message)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user