feat(capture): add minimal browser extension
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { buildCaptureUrl } from "./capture-url.mjs";
|
||||
|
||||
const menuId = "save-vacancy-to-jobjakt";
|
||||
|
||||
function openCapture(pageUrl) {
|
||||
const captureUrl = buildCaptureUrl(pageUrl);
|
||||
if (captureUrl) chrome.tabs.create({ url: captureUrl });
|
||||
}
|
||||
|
||||
chrome.runtime.onInstalled.addListener(() => {
|
||||
chrome.contextMenus.removeAll(() => {
|
||||
chrome.contextMenus.create({
|
||||
id: menuId,
|
||||
title: "Save vacancy to Jobjakt",
|
||||
contexts: ["page", "link"]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
chrome.action.onClicked.addListener((tab) => openCapture(tab.url));
|
||||
chrome.contextMenus.onClicked.addListener((info, tab) => {
|
||||
if (info.menuItemId === menuId) openCapture(info.linkUrl || info.pageUrl || tab?.url);
|
||||
});
|
||||
Reference in New Issue
Block a user