Skip to content

Commit

Permalink
Merge pull request #5 from SayanthD/master
Browse files Browse the repository at this point in the history
popup.js: Inform when copied to clipboard
  • Loading branch information
kairi003 authored Mar 8, 2023
2 parents 3a140ee + ab2f98a commit 969af77
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ h1 {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
text-align: center;
}

h1 > span#location {
color: blue;
}

main {
Expand Down
7 changes: 5 additions & 2 deletions src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const getUrl = chrome.tabs.query({ active: true, currentWindow: true })
const jsonToNetscapeMapper = (jsonData) => {
return jsonData.map(({ domain, expirationDate, path, secure, name, value }) => {
const includeSubDomain = !!domain?.startsWith('.');
const expiry = expirationDate?.toFixed() ?? '';
const expiry = expirationDate?.toFixed() ?? '0';
const arr = [domain, includeSubDomain, path, secure, expiry, name, value];
return arr.map(v => (typeof v === 'boolean') ? v.toString().toUpperCase() : v);
});
Expand Down Expand Up @@ -84,7 +84,10 @@ const setClipboard = async (text) => {
const type = 'text/plain';
const blob = new Blob([text], { type });
const data = [new ClipboardItem({ [type]: blob })];
navigator.clipboard.write(data);
navigator.clipboard.write(data)
.then(() => {
document.getElementById('copy').innerText = 'Copied!';
})
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Format = {
}
type CookieJson = {
"domain": string;
"expirationDate": ?number;
"expirationDate": number | undefined;
"hostOnly": boolean;
"httpOnly": boolean;
"name": string;
Expand Down

0 comments on commit 969af77

Please sign in to comment.