-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
24 lines (20 loc) · 1.02 KB
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('generateButton').addEventListener('click', generateBibliography);
document.getElementById('copyButton').addEventListener('click', copyToClipboard);
});
function generateBibliography() {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
const currentTab = tabs[0];
const pageTitle = decodeURIComponent(currentTab.title);
const pageURL = decodeURIComponent(currentTab.url);
const options = { day: '2-digit', month: '2-digit', year: 'numeric' };
const currentDate = new Date().toLocaleDateString('en-GB', options).replace(/\//g, '.');
const bibliographicLink = `${pageTitle}. URL: ${pageURL} (дата звернення: ${currentDate});`;
document.getElementById('bibliography').value = bibliographicLink;
});
}
function copyToClipboard() {
const bibliographyText = document.getElementById('bibliography');
bibliographyText.select();
document.execCommand('copy');
}