Skip to content

Commit

Permalink
chore: simplify anchor gathering
Browse files Browse the repository at this point in the history
  • Loading branch information
igorlogius committed Mar 28, 2024
1 parent c970666 commit ad31ad0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 43 deletions.
11 changes: 10 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,16 @@ browser.menus.create({
// link
createTempContainerTab(clickdata.linkUrl, openAsActive);
} else if (clickdata.selectionText) {
const links = await browser.tabs.sendMessage(tab.id, "getLinks");
const ret = await browser.tabs.executeScript({
code: `
selection = getSelection();
[...document.links]
.filter((anchor) => selection.containsNode(anchor, true))
.map((link) => link.href );
`,
});

const links = ret[0];

for (const link of links) {
createTempContainerTab(link, false);
Expand Down
33 changes: 0 additions & 33 deletions content.js

This file was deleted.

11 changes: 2 additions & 9 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
"description": "Open current tab url in multiple temp container"
}
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"all_frames": true,
"js": ["content.js"],
"run_at": "document_start"
}
],
"description": "Open the page,tab,link or bookmark in a new temporary container tab",
"icons": {
"96": "icon.png"
Expand All @@ -35,6 +27,7 @@
"page": "options.html"
},
"permissions": [
"activeTab",
"webNavigation",
"storage",
"contextualIdentities",
Expand All @@ -43,5 +36,5 @@
"tabs"
],
"optional_permissions": ["bookmarks", "history"],
"version": "1.1.24"
"version": "1.1.25"
}

0 comments on commit ad31ad0

Please sign in to comment.