From 9d7176722708ec540d0a12c73839ee680af49a3f Mon Sep 17 00:00:00 2001 From: Mohammad Afroz Alam Date: Wed, 10 Sep 2025 02:17:25 +0530 Subject: [PATCH] Add keyboard shortcut (Alt+P) for printing --- src/background.js | 8 ++++++++ src/manifest.json | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/background.js b/src/background.js index 02539f7..706bb9d 100644 --- a/src/background.js +++ b/src/background.js @@ -1,5 +1,13 @@ const GITHUB_MARKDOWN_PRINTER = 'GITHUB_MARKDOWN_PRINTER'; +// Respond to keyboard shortcut commands +chrome.commands.onCommand.addListener((command) => { + chrome.tabs.query({ active: true, lastFocusedWindow: true }, function (tabs) { + let currentTab = tabs[0]; + printPageForTab(currentTab.id); + }); +}); + // Respond to clicks on the extension icon chrome.action.onClicked.addListener((tab) => { printPageForTab(tab.id); diff --git a/src/manifest.json b/src/manifest.json index 33cb865..04a24af 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -26,5 +26,14 @@ "resources": ["style.css"], "matches": ["https://*.github.com/*"] } - ] + ], + "host_permissions": ["https://*.github.com/*"], + "commands": { + "print": { + "suggested_key": { + "default": "Alt+P" + }, + "description": "Attempts to print the markdown" + } + } }