Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #2191, add context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ianb committed Mar 3, 2017
1 parent 6950237 commit a65b7c3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ The primary change was in `server/src/pages/shot/share-buttons.js`
2. ~~Daily ping (attempt roughly every 24 hours) `addon/daily-ping`~~ (removed for launch)
1. [x] Click shot button `addon/start-shot/toolbar-pageshot-button`
2. [ ] Use keyboard shortcut to start shot `addon/start-shot/keyboard-shortcut` (accel-alt-control-c) (FIXME: not yet implemented)
3. [ ] Use the right-click context menu to start a shot `addon/start-shot/context-menu` (FIXME: not yet implemented)
3. [x] Use the right-click context menu to start a shot `addon/start-shot/context-menu`
2. [x] Make a selection `addon/make-selection/selection-drag` with `cd2: {px width}, cd1: {px height}`
3. [x] Make a selection by clicking on an element `addon/make-selection/selection-click` with `cd2: {px width}, cd1: {px height}`
4. [x] Click but fail to find an element that can be selected `addon/no-selection/no-element-found` (error case, not sure when it happens)
Expand Down
24 changes: 21 additions & 3 deletions webextension/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,29 @@ window.main = (function () {

chrome.browserAction.onClicked.addListener(function(tab) {
sendEvent("start-shot", "toolbar-pageshot-button");
loadSelector().catch((e) => {
console.error("Error loading scripts:", e);
});
catcher.watchPromise(loadSelector());
});

chrome.contextMenus.create({
id: "create-pageshot",
title: "Create Page Shot",
contexts: ["page"]
}, () => {
if (chrome.runtime.lastError) {
catcher.unhandled(new Error(chrome.runtime.lastError.message));
}
});

chrome.contextMenus.onClicked.addListener(catcher.watchFunction((info, tab) => {
if (! tab) {
// Not in a page/tab context, ignore
return;
}
sendEvent("start-shot", "context-menu");
catcher.watchPromise(loadSelector());
}));


communication.register("sendEvent", (...args) => {
catcher.watchPromise(sendEvent(...args));
// We don't wait for it to complete:
Expand Down
1 change: 1 addition & 0 deletions webextension/manifest.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"storage",
"notifications",
"clipboardWrite",
"contextMenus",
"<all_urls>",
"http://localhost:10080/"
]
Expand Down

0 comments on commit a65b7c3

Please sign in to comment.