mirror of
https://github.com/tubearchivist/browser-extension.git
synced 2025-03-12 16:40:14 +00:00
add show cookie button
This commit is contained in:
parent
53c5e7f077
commit
68bf0fa5d7
@ -179,10 +179,8 @@ function buildCookieLine(cookie) {
|
|||||||
].join('\t');
|
].join('\t');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendCookies() {
|
async function getCookieLines() {
|
||||||
console.log('function sendCookies');
|
|
||||||
const acceptableDomains = ['.youtube.com', 'youtube.com', 'www.youtube.com'];
|
const acceptableDomains = ['.youtube.com', 'youtube.com', 'www.youtube.com'];
|
||||||
|
|
||||||
let cookieStores = await browserType.cookies.getAllCookieStores();
|
let cookieStores = await browserType.cookies.getAllCookieStores();
|
||||||
let cookieLines = [
|
let cookieLines = [
|
||||||
'# Netscape HTTP Cookie File',
|
'# Netscape HTTP Cookie File',
|
||||||
@ -202,7 +200,12 @@ async function sendCookies() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return cookieLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sendCookies() {
|
||||||
|
console.log('function sendCookies');
|
||||||
|
let cookieLines = await getCookieLines();
|
||||||
let response = cookieStr(cookieLines);
|
let response = cookieStr(cookieLines);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
@ -244,6 +247,7 @@ type Message =
|
|||||||
| { type: 'verify' }
|
| { type: 'verify' }
|
||||||
| { type: 'cookieState' }
|
| { type: 'cookieState' }
|
||||||
| { type: 'sendCookie' }
|
| { type: 'sendCookie' }
|
||||||
|
| { type: 'getCookieLines' }
|
||||||
| { type: 'continuousSync', checked: boolean }
|
| { type: 'continuousSync', checked: boolean }
|
||||||
| { type: 'download', url: string }
|
| { type: 'download', url: string }
|
||||||
| { type: 'subscribe', url: string }
|
| { type: 'subscribe', url: string }
|
||||||
@ -268,6 +272,9 @@ function handleMessage(request, sender, sendResponse) {
|
|||||||
case 'sendCookie': {
|
case 'sendCookie': {
|
||||||
return await sendCookies();
|
return await sendCookies();
|
||||||
}
|
}
|
||||||
|
case 'getCookieLines': {
|
||||||
|
return await getCookieLines();
|
||||||
|
}
|
||||||
case 'continuousSync': {
|
case 'continuousSync': {
|
||||||
return await handleContinuousCookie(request.checked);
|
return await handleContinuousCookie(request.checked);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
<span>Continuous Cookie Sync</span>
|
<span>Continuous Cookie Sync</span>
|
||||||
</div>
|
</div>
|
||||||
<button id="sendCookies">Copy Now</button>
|
<button id="sendCookies">Copy Now</button>
|
||||||
|
<button id="showCookies">Show Cookie</button><br>
|
||||||
|
<textarea id="cookieLinesResponse" readonly></textarea>
|
||||||
</div>
|
</div>
|
||||||
<p>Download:</p>
|
<p>Download:</p>
|
||||||
<div class="options">
|
<div class="options">
|
||||||
|
@ -78,6 +78,11 @@ document.getElementById('sendCookies').addEventListener('click', function () {
|
|||||||
sendCookie();
|
sendCookie();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// show cookies
|
||||||
|
document.getElementById('showCookies').addEventListener('click', function () {
|
||||||
|
showCookies();
|
||||||
|
});
|
||||||
|
|
||||||
// continuous sync
|
// continuous sync
|
||||||
document.getElementById('continuous-sync').addEventListener('click', function () {
|
document.getElementById('continuous-sync').addEventListener('click', function () {
|
||||||
toggleContinuousSync();
|
toggleContinuousSync();
|
||||||
@ -121,6 +126,29 @@ function sendCookie() {
|
|||||||
sending.then(handleResponse, handleError);
|
sending.then(handleResponse, handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showCookies() {
|
||||||
|
console.log('popup show cookies');
|
||||||
|
const textArea = document.getElementById('cookieLinesResponse');
|
||||||
|
|
||||||
|
function handleResponse(message) {
|
||||||
|
textArea.value = message.join('\n');
|
||||||
|
textArea.style.display = 'initial';
|
||||||
|
}
|
||||||
|
function handleError(error) {
|
||||||
|
console.log(`Error: ${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textArea.value) {
|
||||||
|
textArea.value = '';
|
||||||
|
textArea.style.display = 'none';
|
||||||
|
document.getElementById('showCookies').textContent = 'Show Cookie';
|
||||||
|
} else {
|
||||||
|
let sending = sendMessage({ type: 'getCookieLines' });
|
||||||
|
sending.then(handleResponse, handleError);
|
||||||
|
document.getElementById('showCookies').textContent = 'Hide Cookie';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toggleContinuousSync() {
|
function toggleContinuousSync() {
|
||||||
const checked = document.getElementById('continuous-sync').checked;
|
const checked = document.getElementById('continuous-sync').checked;
|
||||||
let toStore = {
|
let toStore = {
|
||||||
|
@ -81,3 +81,8 @@ button:hover {
|
|||||||
color: red;
|
color: red;
|
||||||
display: none; /* will be made visible when an error occurs */
|
display: none; /* will be made visible when an error occurs */
|
||||||
}
|
}
|
||||||
|
#cookieLinesResponse {
|
||||||
|
display: none;
|
||||||
|
width: 100%;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user