mirror of
https://github.com/tubearchivist/browser-extension.git
synced 2024-11-22 03:30:14 +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) {
|
||||
return [
|
||||
cookie.domain,
|
||||
cookie.hostOnly.toString().toUpperCase(),
|
||||
"TRUE",
|
||||
cookie.path,
|
||||
cookie.httpOnly.toString().toUpperCase(),
|
||||
cookie.expirationDate,
|
||||
@ -165,8 +180,10 @@ async function sendCookies() {
|
||||
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) {
|
||||
console.log("backgound: " + JSON.stringify(request));
|
||||
let response = sendCookies();
|
||||
response.then(message => {
|
||||
sendResponse(message)
|
||||
})
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user