Skip to content

Commit

Permalink
fix: broken format option (#21)
Browse files Browse the repository at this point in the history
Refs: #20
  • Loading branch information
zaki-yama committed Feb 4, 2020
1 parent 21b25af commit 38bc9c0
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions src/popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,24 @@ document.addEventListener("DOMContentLoaded", function() {
};

chrome.tabs.query(queryInfo, function(tabs) {
chrome.storage.sync.get(
{ customFormat: "[${title}](${url})" },
async function(options) {
const tab = tabs[0];
// Encode (, ), [, ]
const url = tab.url
.replace(/\(/g, escape)
.replace(/\)/g, escape)
.replace(/\[/g, escape)
.replace(/\]/g, escape);
await navigator.clipboard.writeText(
options.customFormat
.replace("${title}", tab.title)
.replace("${url}", url)
);
chrome.storage.local.get({ format: "[${title}](${url})" }, async function(
options
) {
const tab = tabs[0];
// Encode (, ), [, ]
const url = tab.url
.replace(/\(/g, escape)
.replace(/\)/g, escape)
.replace(/\[/g, escape)
.replace(/\]/g, escape);
await navigator.clipboard.writeText(
options.format.replace("${title}", tab.title).replace("${url}", url)
);

ReactDOM.render(
<Popup title={tab.title} url={url} />,
document.getElementById("popup")
);
}
);
ReactDOM.render(
<Popup title={tab.title} url={url} />,
document.getElementById("popup")
);
});
});
});

0 comments on commit 38bc9c0

Please sign in to comment.