-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
32 lines (26 loc) · 1.19 KB
/
Copy pathcontent.js
File metadata and controls
32 lines (26 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Listen for messages from popup.js
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === "generateCitation") {
const title = document.title;
const url = window.location.href;
const citation = `"${title}". Retrieved from ${url}`;
// Create an overlay for displaying the citation
const citationOverlay = document.createElement('div');
citationOverlay.innerText = citation;
citationOverlay.style.position = 'fixed';
citationOverlay.style.bottom = '10px';
citationOverlay.style.right = '10px';
citationOverlay.style.backgroundColor = '#f9f9f9';
citationOverlay.style.border = '1px solid #000';
citationOverlay.style.padding = '10px';
citationOverlay.style.zIndex = '10000';
citationOverlay.style.boxShadow = '0px 0px 10px rgba(0,0,0,0.5)';
// Append overlay to the body
document.body.appendChild(citationOverlay);
// Auto-hide the overlay after 5 seconds
setTimeout(() => {
document.body.removeChild(citationOverlay);
}, 5000);
sendResponse({ status: "Citation generated" });
}
});