Pith - grit
grit/grit_chrome/background.js [0.8 kb]
Modified: 18:55:48 154 026 (20 Aug 026)
3 Days Ago
const MENU_ID = "grit-copy";

function inject(tabId, frameIds) {
  chrome.scripting
    .executeScript({
      target: frameIds ? { tabId, frameIds } : { tabId, allFrames: true },
      files: ["grit.js"]
    })
    .catch(() => {});
}

chrome.runtime.onInstalled.addListener(() => {
  chrome.contextMenus.removeAll(() => {
    chrome.contextMenus.create({
      id: MENU_ID,
      title: "Copy Git",
      contexts: ["selection"]
    });
  });
});

chrome.contextMenus.onClicked.addListener((info, tab) => {
  if (info.menuItemId !== MENU_ID || !tab?.id) return;
  inject(tab.id, [info.frameId ?? 0]);
});

chrome.commands.onCommand.addListener(async (name, tab) => {
  if (name !== "copy-git") return;
  const id = tab?.id ?? (await chrome.tabs.query({ active: true, currentWindow: true }))[0]?.id;
  if (id) inject(id);
});
Updates
Kerf - Android 157.026
Kiln - Android 157.026
Wedge - Android 156.026
Whittle - Linux 155.026
Grit - Firefox/Chrome 154.026

Menu
Calendar
Project Tin (024/029)
Miter
RSS Feed
User Avatar
@vgmlr
=SUM(parts)
0.00204
256,973 (+227)