-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
35 lines (30 loc) · 1.04 KB
/
background.js
File metadata and controls
35 lines (30 loc) · 1.04 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
31
32
33
34
35
const CONTEXT_MENU_ID = "verify-with-reality-button";
chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({
id: CONTEXT_MENU_ID,
title: "Verify with The Reality Button",
contexts: ["selection"]
});
});
chrome.contextMenus.onClicked.addListener(async (info, tab) => {
if (info.menuItemId !== CONTEXT_MENU_ID) return;
const selectedText = (info.selectionText || "").trim();
if (!selectedText) return;
try {
await chrome.storage.session.set({
credcheck_selection: selectedText,
credcheck_autorun: true
});
// Chrome 127+ supports action.openPopup() broadly.
// Earlier versions may reject this unless policy-installed.
if (chrome.action && typeof chrome.action.openPopup === "function") {
try {
await chrome.action.openPopup();
} catch (popupError) {
console.warn("Could not auto-open popup. User can click the extension icon manually.", popupError);
}
}
} catch (error) {
console.error("Failed to save selection for popup:", error);
}
});