diff --git a/README.md b/README.md new file mode 100644 index 0000000..ce56492 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +bookmark tabs to right + + +Except as otherwise noted, this software is distributed under the terms of the GNU General Public License, version 2 or later. See LICENSE for the full text. Alternate licensing is available. \ No newline at end of file diff --git a/background.js b/background.js new file mode 100644 index 0000000..b016894 --- /dev/null +++ b/background.js @@ -0,0 +1,51 @@ +function showBookmarkWindow(tabs) { + browser.windows.create({ + type: "popup", url: "/bookmarks.html", + top: 0, left: 0, width: 500, height: 250 + }).then( + (window) => { + browser.tabs.onUpdated.addListener( + (tabid, change, tab) => { + if (tabid == window.tabs[0].id && tab.status == 'complete') { + browser.runtime.sendMessage({ + type: "add-bookmarks", + pages: tabs.map((t) => ({ + index: t.index, + title: t.title, + url: t.url}) + ) + }); + browser.tabs.onUpdated.removeListener(this); + } + }); + }, onerror); +} + +function bookmarkRight(window, index) { + browser.tabs.query({windowId: window}).then( + (tabs) => { + showBookmarkWindow(tabs.filter((t) => t.index > index)); + }); +} + +browser.contextMenus.create({ + contexts: ['tab'], + id: 'bookmark-right', + title: "Bookmark Tabs to the Right" + }); +browser.contextMenus.onClicked.addListener((info, tab) => { + if (info.menuItemId == 'bookmark-right') { + bookmarkRight(tab.windowId, tab.index); + } + }); + +browser.commands.onCommand.addListener((command) => { + if (command == 'bookmark-right') { + browser.tabs.query({ + active: true, + windowId: browser.windows.WINDOW_ID_CURRENT + }).then((tabs) => { + bookmarkRight(browser.windows.WINDOW_ID_CURRENT, tabs[0].index); + }); + } + }); diff --git a/bookmarkright.svg b/bookmarkright.svg new file mode 100644 index 0000000..cbf1074 --- /dev/null +++ b/bookmarkright.svg @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/bookmarks.css b/bookmarks.css new file mode 100644 index 0000000..fb024d4 --- /dev/null +++ b/bookmarks.css @@ -0,0 +1,136 @@ +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} + +button { + -moz-appearance: button; + margin: 0px 5px 2px; + padding: 4px; + min-width: 6.3em; + color: ButtonText; + text-shadow: none; +} + +input { + font: -moz-field; +} + +html, body { + width: 100%; + min-height: 250px; + font: -moz-dialog; + background-color: -moz-Dialog; + color: -moz-DialogText +} + +input[type=checkbox] { + -moz-appearance: none; + margin: 0; + + -moz-context-properties: fill, stroke; + fill: #2292d0; + stroke: none; + width: 21px; + height: 21px; +} + +input[type=checkbox]:checked { + background: url("chrome://global/skin/in-content/check.svg") +} + +.content { + display: grid; + grid-gap: 3px; + margin: 5px; +} + +.content > * { + grid-column: 2; +} + +.content > label { + margin-top: 3px; + grid-column: 1; +} + +#bookmarks { + display: grid; + grid-gap: 3px; + + overflow-y: scroll; + max-height: 250px; + padding: 5px; + background-color: -moz-Field; + color: -moz-FieldText; + font: -moz-list; + -moz-appearance: treeview; +} + +#bookmarks > * { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +#bookmarks > *:nth-child(3n+1) { + grid-column: 1; +} +#bookmarks > *:nth-child(3n+2) { + grid-column: 2; +} +#bookmarks > *:nth-child(3n+3) { + grid-column: 3; +} + +#folder { + font: -moz-list; + padding: 2px 0px; +} + +.buttons { + display: flex; +} + +.buttons::before { + content: ' '; + flex: auto; +} \ No newline at end of file diff --git a/bookmarks.html b/bookmarks.html new file mode 100644 index 0000000..e1cb039 --- /dev/null +++ b/bookmarks.html @@ -0,0 +1,26 @@ + + + +
+ + +