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

Fix #2191, add context menu #2281

Merged
merged 1 commit into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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