Skip to content
Open
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
6 changes: 6 additions & 0 deletions addon/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ browser.contextMenus.create({
documentUrlPatterns: ["<all_urls>"],
});

browser.commands.onCommand.addListener(async command => {
if (command === "toggle-sidebar") {
await browser.sidebarAction.toggle();
}
});

browser.contextMenus.onClicked.addListener(async (info, tab) => {
let url;
let favIconUrl;
Expand Down
16 changes: 16 additions & 0 deletions addon/content-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function getLinkNode(e) {
let target = e.target;
while ((target.tagName !== "A" || !target.href) && target.parentNode) {
target = target.parentNode;
}
return target;
}

function openUrl(e) {
let target = getLinkNode(e);
if (target.tagName !== "A" || !e.altKey) return;

browser.runtime.sendMessage({type: "openUrl", url: target.href});
}

window.addEventListener("click", openUrl);
14 changes: 14 additions & 0 deletions addon/manifest.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,26 @@
"strict_min_version": "57.0a1"
}
},
"commands": {
"toggle-sidebar": {
"suggested_key": {
"default": "Alt+1"
},
"description": "Toggle the sidebar"
}
},
"background": {
"scripts": [
"build/buildSettings.js",
"background.js"
]
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content-script.js"]
}
],
"browser_action": {
"default_icon": "side-view.svg",
"default_popup": "popup.html",
Expand Down
Loading