diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..0510750 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,33 @@ +--- +name: Bug report +about: Create a report to help us improve the extension +title: '' +labels: bug +assignees: '' + +--- + +### Description +A clear and concise description of what the bug is. + +### Reproduction steps +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '...' +3. Scroll down to '...' +4. See error + +### Expected behavior +A clear and concise description of what you expected to happen. + +### Screenshots +If applicable, add screenshots to help explain your problem. + +### Environment +Please provide the following information: + - Operating System: [e.g. Windows 10 Pro 1909 (10.0.18363)] + - Browser: [e.g. Microsoft Edge 83.0.478.56] + - Extension version: [e.g. 1.5] + +### Additional context +Add any other context about the problem here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..d85c3dd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when '...' + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..2904fca --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,9 @@ +Implements following issues: + +## Changelog +- Item 1 +- Item 2 +- Item 3 + +## PR Checklist +- [ ] Change extension version in the manifest \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..1369b35 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at opensource@xfox111.net. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f52250d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,204 @@ +# Contribution Guidelines +Welcome, and thank you for your interest in contributing to my project! + +There are many ways in which you can contribute, beyond writing code. The goal of this document is to provide a high-level overview of how you can get involved. + +## Table of Contents +- [Contribution Guidelines](#gutschedule-contribution-guidelines) + - [Table of Contents](#table-of-contents) + - [Asking Questions](#asking-questions) + - [Providing Feedback](#providing-feedback) + - [Reporting Issues](#reporting-issues) + - [Look For an Existing Issue](#look-for-an-existing-issue) + - [Writing Good Bug Reports and Feature Requests](#writing-good-bug-reports-and-feature-requests) + - [Final Checklist](#final-checklist) + - [Follow Your Issue](#follow-your-issue) + - [Contributing to codebase](#contributing-to-codebase) + - [Deploy test version on your browser](#deploy-test-version-on-your-browser) + - [Development workflow](#development-workflow) + - [Release](#release) + - [Coding guidelines](#coding-guidelines) + - [Indentation](#indentation) + - [Names](#names) + - [Comments](#comments) + - [Strings](#strings) + - [Style](#style) + - [Finding an issue to work on](#finding-an-issue-to-work-on) + - [Contributing to translations](#contributing-to-translations) + - [Submitting pull requests](#submitting-pull-requests) + - [Spell check errors](#spell-check-errors) + - [Thank You!](#thank-you) + - [Attribution](#attribution) + +## Asking Questions +Have a question? Rather than opening an issue, please ask me directly on opensource@xfox111.net. + +## Providing Feedback +Your comments and feedback are welcome. +You can leave your feedbak on feedback@xfox111.net or do it on [Microsoft Edge Add-ons Webstore](https://microsoftedge.microsoft.com/addons/detail/tabs-aside/kmnblllmalkiapkfknnlpobmjjdnlhnd) or [Chrome Webstore](https://chrome.google.com/webstore/detail/tabs-aside/mgmjbodjgijnebfgohlnjkegdpbdjgin) + +## Reporting Issues +Have you identified a reproducible problem in the extension? Have a feature request? I'd like to hear it! Here's how you can make reporting your issue as effective as possible. + +### Look For an Existing Issue +Before you create a new issue, please do a search in [open issues](https://github.com/xfox111/ChromiumTabsAside/issues) to see if the issue or feature request has already been filed. + +Be sure to scan through the [feature requests](https://github.com/XFox111/ChromiumTabsAside/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement). + +If you find your issue already exists, make relevant comments and add your [reaction](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments). Use a reaction in place of a "+1" comment: + +* 👍 - upvote +* 👎 - downvote + +If you cannot find an existing issue that describes your bug or feature, create a new issue using the guidelines below. + +### Writing Good Bug Reports and Feature Requests +File a single issue per problem and feature request. Do not enumerate multiple bugs or feature requests in the same issue. + +Do not add your issue as a comment to an existing issue unless they are the same ones. Many issues look similar, but have different causes. + +The more information you can provide, the more likely someone will be successful at reproducing the issue and finding a solution. + +Please include the following with each issue: +- Current version of the extension +- Your current browser and OS name +- Reproducible steps (1... 2... 3...) that cause the issue +- What you expected to see, versus what you actually saw +- Images, animations, or a link to a video showing the issue occurring + +### Final Checklist +Please remember to do the following: +- [ ] Search the issue repository to ensure your report is a new issue +- [ ] Separate issues reports +- [ ] Include as much information as you can to your report + +Don't feel bad if the developers can't reproduce the issue right away. They will simply ask for more information! + +### Follow Your Issue +Once your report is submitted, be sure to stay in touch with the devs in case they need more help from you. + +## Contributing to codebase +If you are interested in writing code to fix issues or implement new awesome features you can follow this guidelines to get a better result + +### Deploy test version on your browser +1. Clone repository to local storage using [Git](https://guides.github.com/introduction/git-handbook/) + ``` + git clone https://github.com/xfox111/ChromiumTabsAside.git + ``` +2. Enable Developers mode on your browser extensions page +3. Click "Load unpacked" button and navigate to the extension root folder (contains `manifest.json`) +4. Done! + +Next time you make any changes to the codebase, reload extension by toggling it off and on or by pressing "Reload" button on extensions list page + +### Development workflow +This section represents how contributors should interact with codebase implementing features and fixing bugs +1. Getting assigned to the issue +2. Creating a repository fork +3. Making changes to codebase +5. Creating a pull request to `master` +6. Reviewing & completing PR +7. Done + +#### Release +Next stage is release. Release performs on every push to master (which makes functional changes to the source code). Release performs manually by @XFox111 into: Chrome webstore, Edge webstore and GitHub releases + +### Coding guidelines +#### Indentation +We use tabs, not spaces. + +#### Names +The project naming rules inherit [.NET Naming Guidelines](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/naming-guidelines). Nevertheless there'is some distinction with the guidelines as well as additions to the one: +- Use `camelCase` for variables instead of `CamelCase` stated in [Capitalization Conventions](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/capitalization-conventions#capitalization-rules-for-identifiers) +- Use `snake_case` for file names + +#### Comments +Leave as more comments as you can. Remember: the more detailed documentation your code has the less programmers will curse you in the future + +#### Strings +Use "double quotes" wherever it's possible + +#### Style +- Prefer to use lambda functions +- Put curly braces on new lines + - Wrong: + ``` + if (condition) { + ... + } + ``` + - Correct: + ``` + if (condition) + { + ... + } + ``` +- Put spaces between operators and before braces in methods declarations, conditionals and loops + - Wrong: + - `y=k*x+b` + - `function FunctionName()` + - Correct: + - `y = k * x + b` + - `function FunctionName ()` +- Use ternary conditionals wherever it's possible + - Wrong: + ``` + var s; + if (condition) + s = "Life"; + else + s = "Death" + ``` + - Correct: + ``` + var s = condition ? "Life" : "Death"; + ``` +- Do not surround loop and conditional bodies with curly braces if they can be avoided + - Wrong: + ``` + if (condition) + { + console.log("Hello, World!"); + } + else + { + return; + } + ``` + - Correct + ``` + if (condition) + console.log("Hello, World!"); + else + return; + ``` + +### Finding an issue to work on +Check out the [full issues list](https://github.com/XFox111/ChromiumTabsAside/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue) for a list of all potential areas for contributions. **Note** that just because an issue exists in the repository does not mean we will accept a contribution. There are several reasons we may not accept a pull request like: + +- Performance - One of Tabs Aside core values is to deliver a lightweight extension, that means it should perform well in both real and test environments. +- User experience - Since we want to deliver a lightweight extension, the UX should feel lightweight as well and not be cluttered. Most changes to the UI should go through the issue owner and project owner (@XFox111). +- Architectural - Project owner needs to agree with any architectural impact a change may make. Such things must be discussed with and agreed upon by the project owner. + +To improve the chances to get a pull request merged you should select an issue that is labelled with the `help-wanted` or `bug` labels. If the issue you want to work on is not labelled with `help-wanted` or `bug`, you can start a conversation with the project owner asking whether an external contribution will be considered. + +To avoid multiple pull requests resolving the same issue, let others know you are working on it by saying so in a comment. + +### Contributing to translations +If you want to help us to translate this extension into other languages, please read [this article](https://developer.chrome.com/extensions/i18n) + +**Note** that whatever you want to contribute to the codebase, you should do it only after you got assigned on an issue + +### Submitting pull requests +To enable us to quickly review and accept your pull requests, always create one pull request per issue and [link the issue in the pull request](https://github.com/blog/957-introducing-issue-mentions). Never merge multiple requests in one unless they have the same root cause. Be sure to follow our [Coding Guidelines](#coding-guidelines) and keep code changes as small as possible. Avoid pure formatting changes to code that has not been modified otherwise. Pull requests should contain tests whenever possible. Fill pull request content according to its template. Deviations from template are not recommended + +#### Spell check errors +Pull requests that fix typos are welcomed but please make sure it doesn't touch multiple feature areas, otherwise it will be difficult to review. Pull requests only fixing spell check errors in source code are not recommended. + +## Thank You! + +Your contributions to open source, large or small, make great projects like this possible. Thank you for taking the time to contribute. + +## Attribution +This Contribution Guidelines are adapted from the [Contributing to VS Code](https://github.com/microsoft/vscode/blob/master/CONTRIBUTING.md) \ No newline at end of file diff --git a/README.md b/README.md index a760bd6..081a6ba 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Unfortunately, in new Chromium-based Microsoft Edge, the devs decided not to imp - Familiar UI inherited from legacy Microsoft Edge with some improvements - Auto Dark mode - Now you can restore one tab from collection without removing +- Now you can choose if you want to load restored tabs only when you're navigating onto them ## Download - [Google Chrome Webstore](https://chrome.google.com/webstore/detail/tabs-aside/mgmjbodjgijnebfgohlnjkegdpbdjgin) @@ -34,7 +35,24 @@ Unfortunately, in new Chromium-based Microsoft Edge, the devs decided not to imp ## Project roadmap You can go to the project's [roadmap kanban board](https://github.com/XFox111/ChromiumTabsAside/projects/1) and see what have we planned and watch our progress in realtime +## Contributing +There are many ways in which you can participate in the project, for example: +- [Submit bugs and feature requests](https://github.com/xfox111/gutschedule/issues), and help us verify as they are checked in +- Review [source code changes](https://github.com/xfox111/gutschedule/pulls) +- Review documentation and make pull requests for anything from typos to new content + +If you are interested in fixing issues and contributing directly to the code base, please see the [Contribution Guidelines](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md), which covers the following: +- [How to deploy the extension on your browser](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md#deploy-test-version-on-your-browser) +- [The development workflow](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md#development-workflow), including debugging and running tests +- [Coding guidelines](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md#coding-guidelines) +- [Submitting pull requests](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md#submitting-pull-requests) +- [Finding an issue to work on](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md#finding-an-issue-to-work-on) +- [Contributing to translations](https://github.com/XFox111/ChromiumTabsAside/blob/master/CONTRIBUTING.md#contributing-to-translations) + +## Code of Conduct +This project has adopted the Contributor Covenant. For more information see the [Code of Conduct](https://github.com/XFox111/ChromiumTabsAside/blob/master/CODE_OF_CONDUCT.md) + ## Copyrights > ©2020 Michael "XFox" Gordeev -Licensed under [MIT License](https://opensource.org/licenses/MIT) +Licensed under [MIT License](https://opensource.org/licenses/MIT) \ No newline at end of file diff --git a/TabsAside.html b/TabsAside.html index b779666..12a9eff 100644 --- a/TabsAside.html +++ b/TabsAside.html @@ -8,55 +8,43 @@ - - - - +
+

You have no aside tabs

+
+ + diff --git a/collections.html b/collections.html deleted file mode 100644 index 6280ef0..0000000 --- a/collections.html +++ /dev/null @@ -1,62 +0,0 @@ -
- -
\ No newline at end of file diff --git a/css/style.css b/css/style.css index 3425240..35f0eed 100644 --- a/css/style.css +++ b/css/style.css @@ -1,260 +1,240 @@ .tabsAside.background { - z-index: 9999 !important; - background-color: rgba(255, 255, 255, .5) !important; - position: fixed !important; - top: 0 !important; - bottom: 0 !important; - right: 0 !important; - left: 0 !important; - transition: .2s !important; - opacity: 0; - color: black !important; + background-color: rgba(255, 255, 255, .5); + position: fixed; + top: 0; + bottom: 0; + right: 0; + left: 0; + transition: .2s; + color: black; } .tabsAside.pane { - font-family: 'Segoe UI', 'Segoe MDL2 Assets' !important; - user-select: none !important; - position: fixed !important; + user-select: none; + position: fixed; - right: 0px !important; - top: 0px !important; - bottom: 0px !important; - overflow: auto !important; + right: 0px; + top: 0px; + bottom: 0px; + overflow: auto; - width: 40%; - min-width: 500px !important; + width: 100%; + min-width: 500px; - background-color: #f7f7f7 !important; - border: 1px solid rgba(100, 100, 100, .5) !important; - border-width: 0px 0px 0px 1px !important; - box-sizing: border-box !important; - box-shadow: 6px 0px 12px black !important; + background-color: #f7f7f7; + border: 1px solid rgba(100, 100, 100, .5); + border-width: 0px 0px 0px 1px; + box-shadow: 6px 0px 12px black; - font-size: small !important; + font-size: 13px; - transform: translateX(110%); /* Pane is hidden */ - transition: .2s !important; - text-align: initial !important; + transform: translateX(110%); /* pane is hidded */ + transition: .2s; } + aside[embedded] + { + width: 40% !important; + } + .tabsAside.pane[opened] { - transform: translateX(0px) !important; + transform: translateX(0px); } /* Pane header*/ .tabsAside.pane > header { - margin: 20px 40px !important; - line-height: initial !important; - height: initial !important; + margin: 20px 40px; } .tabsAside.pane > header > div { - display: grid !important; - grid-template-columns: 1fr auto !important; + display: grid; + grid-template-columns: 1fr auto; } .tabsAside.pane > header > div > h1 { - margin: 10px 0px !important; - font-weight: normal !important; - font-size: 21pt !important; - direction: initial !important; - color: inherit !important; - line-height: initial !important; - font-family: inherit !important; + margin: 10px 0px; + font-weight: normal; + font-size: 21pt; } .tabsAside.pane > header > div > button { - margin: auto !important; + margin: auto; } .tabsAside.pane > header > div > nav { - top: 70px !important; - right: 40px !important; + top: 70px; + right: 40px; } - .tabsAside.pane > header > div > nav > div + .tabsAside.pane > header nav > div { - box-shadow: 0px 4px 5px -2px rgba(100, 100, 100, .5) !important; - cursor: initial !important; - overflow: hidden !important; + box-shadow: 0px 4px 5px -2px rgba(100, 100, 100, .5); } - .tabsAside.pane > header > div > nav > p + .tabsAside.pane > header nav > p { - margin: 10px !important; - font-family: inherit !important; - font-size: inherit !important; - line-height: initial !important; + margin: 10px; } - .tabsAside.pane > header > div > nav > p > small - { - font-size: inherit !important; - font-family: inherit !important; - } - - .tabsAside.pane > header > div > nav > p > a + .tabsAside.pane > header nav > p > a { text-decoration: none; - font-size: inherit !important; - border: none !important; } - .tabsAside.pane > header > a + .iconArrowRight { - font-size: inherit; + width: 13px; + height: 13px; + display: inline-block; + background-repeat: no-repeat; + background-size: 13px; + background-position: center; + background-image: url("chrome-extension://__MSG_@@extension_id__/icons/arrowRight.svg"); } .tabsAside.pane > header > hr { - border: 1px solid #8a8a8a !important; - direction: initial !important; - color: inherit !important; - height: initial !important; - margin: 6.5px 0px !important; + border: 1px solid #8a8a8a; } .tabsAside.pane > section > h2 { - color: inherit !important; - margin: 0px 40px !important; - font-weight: normal !important; - font-size: 1.5em !important; - line-height: normal !important; + margin: 0px 40px; + font-weight: normal; } /* Collection header */ .tabsAside.pane > section > div { - transition: .2s !important; + transition: .2s; } - .tabsAside.pane > section > div > div:first-child + .collectionSet > .header { - margin: 0px 20px !important; - display: grid !important; - grid-template-columns: auto 1fr auto auto auto !important; - grid-column-gap: 10px !important; - align-items: center !important; + margin: 0px 20px; + display: grid; + grid-template-columns: auto 1fr auto auto auto; + grid-column-gap: 10px; + align-items: center; } - .tabsAside.pane > section > div > div:first-child > small + .collectionSet > .header > small { - color: gray !important; - font-size: smaller !important; + color: gray; } - .tabsAside.pane > section > div > div:first-child > span + .collectionSet > .header > span { - font-weight: 600 !important; + font-weight: 600; } - .tabsAside.pane > section > div > div:first-child > a + .collectionSet > .header > a { - font-size: 11pt !important; - line-height: initial !important; + font-size: 11pt; } - .tabsAside.pane > section > div > div:first-child > div > nav - { - width: 250px !important; - margin-top: 40px !important; - right: 50px !important; - } + .collectionSet > .header > div > nav + { + width: 250px; + right: 60px; + } /* Tabs collection */ - .tabsAside.pane > section > div > div:last-child + .collectionSet > .set { - margin: 0px 0px 0px 20px !important; - padding: 10px 40px 10px 20px !important; - white-space: nowrap !important; - overflow: auto !important; + margin: 0px 0px 0px 20px; + padding: 10px 40px 10px 20px; + white-space: nowrap; + overflow: auto; } - .tabsAside.pane > section > div > div:last-child:hover::-webkit-scrollbar-thumb + .collectionSet > .set::-webkit-scrollbar-thumb { - visibility: visible !important; + visibility: hidden; } - .tabsAside.pane > section > div > div:last-child > div + .collectionSet > .set:hover::-webkit-scrollbar-thumb { - width: 175px !important; - height: 148px !important; - margin: 5px !important; + visibility: visible; + } - background-color: #c2c2c2 !important; + .collectionSet > .set > div + { + width: 175px; + height: 148px; + margin: 5px; + + background-color: #c2c2c2; background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_thumbnail.png"); - background-size: cover !important; - background-position-x: center !important; + background-size: cover; + background-position-x: center; - display: inline-grid !important; - grid-template-rows: 1fr auto !important; + display: inline-grid; + grid-template-rows: 1fr auto; - box-shadow: 0px 0px 5px rgba(100, 100, 100, .5) !important; - transition: .25s !important; - cursor: pointer !important; + box-shadow: 0px 0px 5px rgba(100, 100, 100, .5); + transition: .25s; + cursor: pointer; } - .tabsAside.pane > section > div > div:last-child > div:hover + .collectionSet > .set > div:hover { - filter: brightness(120%) !important; - box-shadow: 0px 0px 15px rgba(100, 100, 100, .5) !important; + filter: brightness(120%); + box-shadow: 0px 0px 15px rgba(100, 100, 100, .5); } - .tabsAside.pane > section > div > div:last-child > div > div + .collectionSet > .set > div > div { - background-color: rgba(233, 233, 233, .75) !important; - grid-row: 2 !important; - display: grid !important; - grid-template-columns: auto 1fr auto !important; + background-color: rgba(233, 233, 233, .75); + grid-row: 2; + display: grid; + grid-template-columns: auto 1fr auto; } - .tabsAside.pane > section > div > div:last-child > div > div > button + .collectionSet > .set > div > div > button { - margin: auto !important; - margin-right: 5px !important; - display: none !important; + margin: auto; + margin-right: 5px; + display: none; } - .tabsAside.pane > section > div > div:last-child > div:hover > div > button + .collectionSet > .set > div:hover > div > button { - display: initial !important; + display: initial; } - .tabsAside.pane > section > div > div:last-child > div > div > div + .collectionSet > .set > div > div > div { - width: 20px !important; - height: 20px !important; - margin: 10px !important; + width: 20px; + height: 20px; + margin: 10px; background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_icon.png"); - background-size: 20px !important; + background-size: 20px; } - .tabsAside.pane > section > div > div:last-child > div > div > span + .collectionSet > .set > div > div > span { - overflow: hidden !important; - margin: auto 0px !important; - margin-right: 10px !important; - line-height: initial !important; + overflow: hidden; + margin: auto 0px; + margin-right: 10px; } - .tabsAside.pane > section > div > div:last-child > div:hover > div > span + .collectionSet > .set > div:hover > div > span { - margin-right: 5px !important; + margin-right: 5px; } @media only screen and (max-width: 500px) { .tabsAside.pane { - width: initial !important; - left: 0px !important; - min-width: initial !important; + width: 100% !important; + min-width: initial; } } \ No newline at end of file diff --git a/css/style.dark.css b/css/style.dark.css index 11f541d..214f25f 100644 --- a/css/style.dark.css +++ b/css/style.dark.css @@ -1,59 +1,74 @@ .tabsAside[darkmode].background { - background-color: rgba(0, 0, 0, .5) !important; + background-color: rgba(0, 0, 0, .5); } .tabsAside[darkmode] .pane { - background-color: #333333 !important; - color: white !important; + background-color: #333333; + color: white; } + .tabsAside[darkmode] .saveTabs > div + { + filter: invert(); + } + + /* Button style */ .tabsAside[darkmode] .pane button { - color: white !important; + filter: invert(); } .tabsAside[darkmode] .pane button:hover { - background-color: gray !important; + background-color: gray; } .tabsAside[darkmode] .pane button:active { - background-color: dimgray !important; + background-color: dimgray; } - .tabsAside[darkmode] .pane > section > div > div:first-child > div:first-child > small + .tabsAside[darkmode] a + { + color: #48adff; + } + + /* Timestamp label */ + .tabsAside[darkmode] > .pane > section small { color: lightgray !important; } + /* Scrollbar style */ .tabsAside[darkmode] .pane ::-webkit-scrollbar-thumb { - background: gray !important; - border-radius: 3px !important; + background: gray; + border-radius: 3px; } .tabsAside[darkmode] .pane ::-webkit-scrollbar-thumb:hover { - background: dimgray !important; + background: dimgray; } - .tabsAside[darkmode] .pane > section > div > div:last-child > div + /* Tab style */ + .tabsAside[darkmode] .pane .collectionSet > .set > div { - background-color: #0c0c0c !important; + background-color: #0c0c0c; background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_thumbnail_dark.png"); } - .tabsAside[darkmode] .pane > section > div > div:last-child > div > div + .tabsAside[darkmode] .pane .collectionSet > .set > div > div { - background-color: rgba(50, 50, 50, .75) !important; + background-color: rgba(50, 50, 50, .75); } - .tabsAside[darkmode] .pane > section > div > div:last-child > div > div > div + .tabsAside[darkmode] .pane .collectionSet > .set > div > div > div { background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_icon_dark.png"); } + /* Context menu style */ .tabsAside[darkmode] .pane nav { - background-color: #3f3f3f !important; + background-color: #3f3f3f; } \ No newline at end of file diff --git a/css/style.generic.css b/css/style.generic.css index 7c14a2d..2ce4f0f 100644 --- a/css/style.generic.css +++ b/css/style.generic.css @@ -1,126 +1,115 @@ /* Custom scrollbar */ .tabsAside ::-webkit-scrollbar { - height: 6px !important; + height: 6px; + width: 6px; } .tabsAside ::-webkit-scrollbar-thumb { - visibility: hidden !important; - background: darkgray !important; - border-radius: 3px !important; + background: darkgray; + border-radius: 3px; } .tabsAside ::-webkit-scrollbar-thumb:hover { - background: gray !important; + background: gray; } -.tabsAside::-webkit-scrollbar +.tabsAside { - width: 6px !important; + font-family: 'DefaultFont'; + font-size: 14px; + user-select: none; } -.tabsAside::-webkit-scrollbar-thumb -{ - background: gray !important; - border-radius: 3px !important; -} - .tabsAside::-webkit-scrollbar-thumb:hover - { - background: darkgray !important; - } - /* Links style */ .tabsAside a { - font-family: 'Segoe UI', 'Segoe MDL2 Assets' !important; - color: #0078d7 !important; - font-weight: 400 !important; + color: #0078d7; } .tabsAside a:hover { - text-decoration: underline !important; - cursor: pointer !important; + text-decoration: underline; + cursor: pointer; } .tabsAside a:visited { - color: #0078d7 !important; + color: #0078d7; } /* Buttons style */ .tabsAside button { - font-family: 'Segoe MDL2 Assets' !important; - width: 32px !important; - height: 32px !important; - background-color: transparent !important; - border: none !important; - cursor: pointer !important; - box-shadow: initial !important; - font-size: inherit !important; - padding: initial !important; - position: initial !important; - box-sizing: initial !important; - line-height: initial !important; - text-align: center !important; - border-radius: 2px !important; - min-height: initial !important; - display: initial !important; - min-width: initial !important; + width: 32px; + height: 32px; + background-color: transparent; + border: none; + cursor: pointer; } .tabsAside button:hover { - background-color: #c6c6c6 !important; + background-color: #c6c6c6; } .tabsAside button:active { - background-color: gray !important; + background-color: gray; } /* Context menus style */ .tabsAside nav { - font-family: 'Segoe UI' !important; - user-select: none !important; + user-select: none; - position: absolute !important; - width: 250px !important; + position: absolute; + width: 250px; - box-shadow: 0px 0px 10px black !important; - background-color: white !important; - border-radius: 5px !important; + box-shadow: 0px 0px 10px black; + background-color: white; + border-radius: 5px; - z-index: 10 !important; + z-index: 10; - visibility: hidden !important; - - display: initial !important; - left: initial !important; - bottom: initial !important; - padding: initial !important; - min-height: initial !important; - font-size: inherit !important; + visibility: hidden; } .tabsAside nav button - { - font-family: 'Segoe UI' !important; - cursor: pointer !important; - background-color: transparent !important; - border: none !important; - box-sizing: border-box !important; - - font-size: medium !important; - text-align: start !important; + { + text-align: start; - padding: 10px !important; - width: 100% !important; - height: initial !important; + padding: 0px 10px; + width: 100%; } .tabsAside button + nav:active, .tabsAside button:focus + nav { - visibility: visible !important; - } \ No newline at end of file + visibility: visible; + } + +/* Icon buttons style */ +.btn +{ + background-repeat: no-repeat; + background-size: 15px; + background-position: center; +} + + .btn.more + { + background-image: url("chrome-extension://__MSG_@@extension_id__/icons/more.svg"); + } + + .btn.remove + { + background-image: url("chrome-extension://__MSG_@@extension_id__/icons/cancel.svg"); + } + +@font-face +{ + font-family: 'DefaultFont'; + src: local("Segoe UI"), + url("chrome-extension://__MSG_@@extension_id__/fonts/WeblySleekUI/weblysleekuisemilight.ttf") format("truetype"), + url("chrome-extension://__MSG_@@extension_id__/fonts/WeblySleekUI/weblysleekuisemilight.woff") format("woff"), + url("chrome-extension://__MSG_@@extension_id__/fonts/WeblySleekUI/weblysleekuisemilight.woff2") format("woff2"); +} \ No newline at end of file diff --git a/fonts/WeblySleekUI/weblysleekuisemilight.ttf b/fonts/WeblySleekUI/weblysleekuisemilight.ttf new file mode 100644 index 0000000..7649075 Binary files /dev/null and b/fonts/WeblySleekUI/weblysleekuisemilight.ttf differ diff --git a/fonts/WeblySleekUI/weblysleekuisemilight.woff b/fonts/WeblySleekUI/weblysleekuisemilight.woff new file mode 100644 index 0000000..1cb8db9 Binary files /dev/null and b/fonts/WeblySleekUI/weblysleekuisemilight.woff differ diff --git a/fonts/WeblySleekUI/weblysleekuisemilight.woff2 b/fonts/WeblySleekUI/weblysleekuisemilight.woff2 new file mode 100644 index 0000000..0df9be1 Binary files /dev/null and b/fonts/WeblySleekUI/weblysleekuisemilight.woff2 differ diff --git a/icons/arrowRight.svg b/icons/arrowRight.svg new file mode 100644 index 0000000..187c891 --- /dev/null +++ b/icons/arrowRight.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/icons/cancel.svg b/icons/cancel.svg new file mode 100644 index 0000000..1783883 --- /dev/null +++ b/icons/cancel.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/icons/more.svg b/icons/more.svg new file mode 100644 index 0000000..70d6d17 --- /dev/null +++ b/icons/more.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/js/aside-script.js b/js/aside-script.js index fe38e87..e501cbd 100644 --- a/js/aside-script.js +++ b/js/aside-script.js @@ -1,116 +1,66 @@ -if (document.location.protocol == "chrome-extension:") - InitializeStandalone(); -else +if (window.location === window.parent.location && window.location.protocol != "chrome-extension:") // For open/close call { - setTimeout(function () + var iframe = document.querySelector("iframe.tabsAsideIframe"); + if (!iframe) { - var pane = document.querySelector(".tabsAside.pane"); + iframe = document.createElement('iframe'); - if (pane == null) + iframe.setAttribute("class", "tabsAsideIframe"); + + iframe.style.position = "fixed"; + iframe.style.zIndex = "2147483647"; + + iframe.style.height = "100%"; + iframe.style.width = "100%"; + + iframe.style.top = "0px"; + iframe.style.right = "0px"; + iframe.style.left = "0px"; + iframe.style.bottom = "0px"; + + iframe.style.border = "none"; + iframe.style.background = "transparent"; + iframe.style.opacity = 0; + + var bodyStyle = document.body.getAttribute("style"); + document.body.setAttribute("style", "overflow: hidden !important"); + + iframe.onload = () => setTimeout(() => iframe.style.opacity = 1, 100); + + iframe.src = chrome.extension.getURL("TabsAside.html"); + document.body.appendChild(iframe); + } + else + { + iframe.contentWindow.postMessage({ target: "TabsAside", command: "TogglePane" }, "*"); + setTimeout(() => { - var xhr = new XMLHttpRequest(); - xhr.open('GET', chrome.extension.getURL("collections.html"), true); - xhr.onreadystatechange = function () - { - if (this.status !== 200 || document.querySelector("#aside-pane") != null) - return; - - if (document.querySelector(".tabsAside.pane") == null) - { - document.body.innerHTML += this.responseText; - chrome.runtime.sendMessage({ command: "loadData" }, function (collections) - { - if (document.querySelector(".tabsAside.pane section div") == null) - collections.forEach(i => - { - AddCollection(i); - }); - }); - } - - setTimeout(function () - { - pane = document.querySelector(".tabsAside.pane"); - - if (window.matchMedia("(prefers-color-scheme: dark)").matches) - pane.parentElement.setAttribute("darkmode", ""); - - document.querySelector(".tabsAside .saveTabs").onclick = SetTabsAside; - - document.querySelector("nav > p > small").textContent = chrome.runtime.getManifest()["version"]; - - var loadOnRestoreCheckbox = document.querySelector("nav > p > input[type=checkbox]"); - chrome.storage.sync.get({ "loadOnRestore": false }, - values => loadOnRestoreCheckbox.checked = values.loadOnRestore - ); - chrome.storage.onChanged.addListener(function (changes, namespace) { - if (namespace == 'sync'){ - for (key in changes) { - if (key === 'loadOnRestore') { - loadOnRestoreCheckbox.checked = changes[key].newValue - } - } - } - }); - loadOnRestoreCheckbox.addEventListener("click", function () - { - chrome.storage.sync.set( - { - "loadOnRestore": loadOnRestoreCheckbox.checked - }); - }); - - document.querySelectorAll(".tabsAside.pane > header nav button").forEach(i => - { - i.onclick = function () { window.open(i.value, '_blank'); }; - }); - - document.querySelector(".tabsAside.background").addEventListener("click", function (event) - { - if (event.target == pane.parentElement) - { - pane.removeAttribute("opened"); - pane.parentElement.style.opacity = 0; - document.body.style.overflow = ""; - setTimeout(function () - { - pane.parentElement.remove(); - }, 300); - } - }); - - pane.setAttribute("opened", ""); - pane.parentElement.style.opacity = 1; - document.body.style.overflow = "hidden"; - }, 50); - }; - xhr.send(); - } - else - { - if (pane.hasAttribute("opened")) - { - pane.removeAttribute("opened"); - pane.parentElement.style.opacity = 0; - document.body.style.overflow = ""; - setTimeout(function () - { - if (!pane.hasAttribute("opened")) - pane.parentElement.remove(); - }, 300); - } - else - { - pane.setAttribute("opened", ""); - pane.parentElement.style.opacity = 1; - } - } - }, 50); + iframe.remove(); + document.body.setAttribute("style", bodyStyle); + }, 250); + } } +else // For init call + Initialize(); -function InitializeStandalone() +function Initialize() { - pane = document.querySelector(".tabsAside.pane"); + var pane = document.querySelector(".tabsAside.pane"); + if (!pane) + return; + + if (window.location !== window.parent.location) + { + pane.setAttribute("embedded", ""); + window.addEventListener('message', event => + { + if (event.data.target == "TabsAside") + { + pane.parentElement.style.opacity = 0; + pane.removeAttribute("opened"); + } + }); + } if (window.matchMedia("(prefers-color-scheme: dark)").matches) { @@ -123,39 +73,35 @@ function InitializeStandalone() document.querySelector("nav > p > small").textContent = chrome.runtime.getManifest()["version"]; var loadOnRestoreCheckbox = document.querySelector("nav > p > input[type=checkbox]"); - chrome.storage.sync.get({ "loadOnRestore": false }, + chrome.storage.sync.get( + { "loadOnRestore": false }, values => loadOnRestoreCheckbox.checked = values.loadOnRestore ); - chrome.storage.onChanged.addListener(function (changes, namespace) { - if (namespace == 'sync'){ - for (key in changes) { - if (key === 'loadOnRestore') { - loadOnRestoreCheckbox.checked = changes[key].newValue - } - } - } - }); - loadOnRestoreCheckbox.addEventListener("click", function () + chrome.storage.onChanged.addListener((changes, namespace) => { + if (namespace == 'sync') + for (key in changes) + if (key === 'loadOnRestore') + loadOnRestoreCheckbox.checked = changes[key].newValue + }); + loadOnRestoreCheckbox.addEventListener("click", () => chrome.storage.sync.set( { "loadOnRestore": loadOnRestoreCheckbox.checked - }); - }); + }) + ); document.querySelectorAll(".tabsAside.pane > header nav button").forEach(i => - { - i.onclick = function () { window.open(i.value, '_blank'); }; - }); + i.onclick = () => window.open(i.value, '_blank')); - chrome.runtime.sendMessage({ command: "loadData" }, function (collections) + chrome.runtime.sendMessage({ command: "loadData" }, (collections) => { if (document.querySelector(".tabsAside.pane section div") == null) collections.forEach(i => - { - AddCollection(i); - }); + AddCollection(i)); }); + + setTimeout(() => pane.setAttribute("opened", ""), 100); } function AddCollection(collection) @@ -169,75 +115,53 @@ function AddCollection(collection) { rawTabs += "
" + - "" + - "
" + - "
" + - "" + collection.titles[i] + "" + - "" + - "
" + + "" + + "
" + + "
" + + "" + collection.titles[i] + "" + + "" + + "" + ""; } - list.innerHTML += "
" + - "
" + - "Tabs: " + collection.links.length + "" + - "" + GetAgo(collection.timestamp) + "" + - "Restore tabs" + - "
" + - "" + - "" + - "
" + - "" + - "
" + + list.innerHTML += + "
" + + "
" + + "Tabs: " + collection.links.length + "" + + "" + GetAgo(collection.timestamp) + "" + + "Restore tabs" + + "
" + + "" + + "" + + "
" + + "" + + "
" + - "
" + rawTabs + "
" + + "
" + rawTabs + "
" + "
" - list.querySelectorAll("a").forEach(i => - { - i.onclick = function () { RestoreTabs(i.parentElement.parentElement) }; - }); + list.querySelectorAll(".restoreCollection").forEach(i => + i.onclick = () => RestoreTabs(i.parentElement.parentElement)); - list.querySelectorAll("nav button:first-child").forEach(i => - { - i.onclick = function () { RestoreTabs(i.parentElement.parentElement.parentElement.parentElement, false) }; - }); + list.querySelectorAll(".restoreCollection.noDelete").forEach(i => + i.onclick = () => RestoreTabs(i.parentElement.parentElement.parentElement.parentElement, false)); - list.querySelectorAll("div > div:last-child > div > span").forEach(i => - { - i.onclick = function () - { + list.querySelectorAll(".openTab").forEach(i => + i.onclick = () => chrome.runtime.sendMessage( { command: "openTab", url: i.getAttribute("value") } - ); - }; - }) + )); - document.querySelectorAll(".tabsAside.pane > section > div > div:first-child > button").forEach(i => - { - i.onclick = function () { RemoveTabs(i.parentElement.parentElement) }; - }); + document.querySelectorAll(".btn.remove").forEach(i => + i.onclick = () => RemoveTabs(i.parentElement.parentElement)); - /*document.querySelectorAll(".tabsAside.pane > section > div > div:first-child > div > nav > button:first-child").forEach(i => - { - i.onclick = function () { AddToFavorites(i.parentElement.parentElement.parentElement.parentElement) }; - }); - document.querySelectorAll(".tabsAside.pane > section > div > div:first-child > div > nav > button:last-child").forEach(i => - { - i.onclick = function () { ShareTabs(i.parentElement.parentElement.parentElement.parentElement) }; - });*/ - - document.querySelectorAll(".tabsAside.pane > section > div > div:last-child > div > div > button").forEach(i => - { - i.onclick = function () { RemoveOneTab(i.parentElement.parentElement) }; - }); + document.querySelectorAll(".tabsList .btn.remove").forEach(i => + i.onclick = () => RemoveOneTab(i.parentElement.parentElement)); } function SetTabsAside() @@ -253,85 +177,47 @@ function RestoreTabs(collectionData, removeCollection = true) removeCollection: removeCollection, collectionIndex: Array.prototype.slice.call(collectionData.parentElement.children).indexOf(collectionData) - 1 }, - function () + () => { - if (!removeCollection) - return; - - if (collectionData.parentElement.children.length < 3) - { - RemoveElement(collectionData); - setTimeout(function () - { - document.querySelector(".tabsAside.pane > section > h2").removeAttribute("hidden"); - }, 250); - } - else - RemoveElement(collectionData); + if (removeCollection) + RemoveCollectionElement(collectionData); } ); } function RemoveTabs(collectionData) { + if (!confirm("Are you sure you want to delete this collection?")) + return; + chrome.runtime.sendMessage( { command: "deleteTabs", collectionIndex: Array.prototype.slice.call(collectionData.parentElement.children).indexOf(collectionData) - 1 }, - function () - { - if (collectionData.parentElement.children.length < 3) - { - RemoveElement(collectionData); - setTimeout(function () - { - document.querySelector(".tabsAside.pane > section > h2").removeAttribute("hidden"); - }, 250); - } - else - RemoveElement(collectionData); - } + () => RemoveCollectionElement(collectionData) ); } -function AddToFavorites(collectionData) -{ - chrome.runtime.sendMessage( - { - command: "toFavorites", - collectionIndex: Array.prototype.slice.call(collectionData.parentElement.children).indexOf(collectionData) - 1 - }); -} - -function ShareTabs(collectionData) -{ - chrome.runtime.sendMessage( - { - command: "share", - collectionIndex: Array.prototype.slice.call(collectionData.parentElement.children).indexOf(collectionData) - 1 - }); -} - function RemoveOneTab(tabData) { + if (!confirm("Are you sure you want to delete this tab?")) + return; + chrome.runtime.sendMessage( { command: "removeTab", collectionIndex: Array.prototype.slice.call(tabData.parentElement.parentElement.parentElement.children).indexOf(tabData.parentElement.parentElement) - 1, tabIndex: Array.prototype.slice.call(tabData.parentElement.children).indexOf(tabData) }, - function () + () => { - tabData.parentElement.previousElementSibling.children[0].textContent = "Tabs: " + tabData.parentElement.children.length - 1; + tabData.parentElement.previousElementSibling.children[0].textContent = "Tabs: " + (tabData.parentElement.children.length - 1); if (tabData.parentElement.children.length < 2) { RemoveElement(tabData.parentElement.parentElement); if (document.querySelector("tabsAside.pane > section").children.length < 2) - setTimeout(function () - { - document.querySelector(".tabsAside.pane > section > h2").removeAttribute("hidden"); - }, 250); + setTimeout(() => document.querySelector(".tabsAside.pane > section > h2").removeAttribute("hidden"), 250); } else RemoveElement(tabData); @@ -379,11 +265,12 @@ function GetAgo(timestamp) function RemoveElement(el) { el.style.opacity = 0; - setTimeout(function () - { - el.remove(); - }, 200); + setTimeout(() => el.remove(), 200); } -// TODO: Add more actions -// TODO: Make backup system \ No newline at end of file +function RemoveCollectionElement(el) +{ + RemoveElement(el); + if (el.parentElement.children.length < 2) + setTimeout(() => document.querySelector(".tabsAside.pane > section > h2").removeAttribute("hidden"), 250); +} \ No newline at end of file diff --git a/js/background.js b/js/background.js index a562fc0..f6b4ec8 100644 --- a/js/background.js +++ b/js/background.js @@ -1,28 +1,9 @@ -chrome.browserAction.onClicked.addListener(function (tab) +chrome.browserAction.onClicked.addListener((tab) => { if (tab.url.startsWith("http") && !tab.url.includes("chrome.google.com") && !tab.url.includes("microsoftedge.microsoft.com")) { - chrome.tabs.insertCSS( - { - file: "css/style.css", - allFrames: true, - runAt: "document_idle" - }); - chrome.tabs.insertCSS( - { - file: "css/style.generic.css", - allFrames: true, - runAt: "document_idle" - }); - chrome.tabs.insertCSS( - { - file: "css/style.dark.css", - allFrames: true, - runAt: "document_idle" - }); - chrome.tabs.executeScript(tab.id, { file: "js/aside-script.js", @@ -30,89 +11,38 @@ chrome.browserAction.onClicked.addListener(function (tab) runAt: "document_idle" }); } - else if (tab.url.startsWith("chrome-extension") && tab.url.endsWith("TabsAside.html")) + else if (tab.url == chrome.runtime.getURL("TabsAside.html")) chrome.tabs.remove(tab.id); else { - chrome.tabs.create({ - url: chrome.extension.getURL("TabsAside.html"), - active: true - }, - chrome.tabs.onActivated.addListener(function TabsAsideCloser(activeInfo) { - chrome.tabs.query({ url: chrome.extension.getURL("TabsAside.html") }, function (result) { - if (result.length) - setTimeout(function () { - result.forEach(i => { - if (activeInfo.tabId != i.id) - chrome.tabs.remove(i.id); - }); - }, 200); - else chrome.tabs.onActivated.removeListener(TabsAsideCloser); - }); - })); + chrome.tabs.create( + { + url: chrome.extension.getURL("TabsAside.html"), + active: true + }, + (activeTab) => + chrome.tabs.onActivated.addListener(function TabsAsideCloser(activeInfo) + { + chrome.tabs.query({ url: chrome.extension.getURL("TabsAside.html") }, (result) => + { + if (result.length) + setTimeout(() => + { + result.forEach(i => + { + if (activeInfo.tabId != i.id) + chrome.tabs.remove(i.id); + }); + }, 200); + else chrome.tabs.onActivated.removeListener(TabsAsideCloser); + }); + })); } }); +var collections = JSON.parse(localStorage.getItem("sets")) || []; -function UpdateTheme() -{ - if (window.matchMedia("(prefers-color-scheme: dark)").matches) - { - if (collections.length) - chrome.browserAction.setIcon( - { - path: - { - "128": "icons/dark/full/128.png", - "48": "icons/dark/full/48.png", - "32": "icons/dark/full/32.png", - "16": "icons/dark/full/16.png" - } - }); - else - chrome.browserAction.setIcon( - { - path: - { - "128": "icons/dark/empty/128.png", - "48": "icons/dark/empty/48.png", - "32": "icons/dark/empty/32.png", - "16": "icons/dark/empty/16.png" - } - }); - } - else - { - if (collections.length) - chrome.browserAction.setIcon( - { - path: - { - "128": "icons/light/full/128.png", - "48": "icons/light/full/48.png", - "32": "icons/light/full/32.png", - "16": "icons/light/full/16.png" - } - }); - else - chrome.browserAction.setIcon( - { - path: - { - "128": "icons/light/empty/128.png", - "48": "icons/light/empty/48.png", - "32": "icons/light/empty/32.png", - "16": "icons/light/empty/16.png" - } - }); - } -} - -var collections = JSON.parse(localStorage.getItem("sets")); -if (collections == null) - collections = []; - -chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) +chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { switch (message.command) { @@ -137,33 +67,47 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) RemoveTab(message.collectionIndex, message.tabIndex); sendResponse(); break; - case "toFavorites": - AddTabsToFavorites(message.collectionIndex); - break; - case "share": - ShareTabs(message.collectionIndex); - break; } }); +// This function updates the extension's toolbar icon +function UpdateTheme() +{ + var theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; + var iconStatus = collections.length ? "full" : "empty"; + + var basePath = "icons/" + theme + "/" + iconStatus + "/"; + + chrome.browserAction.setIcon( + { + path: + { + "128": basePath + "128.png", + "48": basePath + "48.png", + "32": basePath + "32.png", + "16": basePath + "16.png" + } + }); +} + UpdateTheme(); chrome.windows.onFocusChanged.addListener(UpdateTheme); - chrome.tabs.onUpdated.addListener(UpdateTheme); chrome.tabs.onActivated.addListener(UpdateTheme); +// Set current tabs aside function SaveCollection() { - chrome.tabs.query({ currentWindow: true }, function (rawTabs) + chrome.tabs.query({ currentWindow: true }, (rawTabs) => { - var tabs = rawTabs.filter(i => !(i.url.startsWith("chrome-extension") && i.url.endsWith("TabsAside.html")) && !i.pinned && !i.url.includes("//newtab")); + var tabs = rawTabs.filter(i => i.url != chrome.runtime.getURL("TabsAside.html") && !i.pinned && !i.url.includes("//newtab")); if (tabs.length < 1) { alert("No tabs available to save"); return; } - + var collection = { timestamp: Date.now(), @@ -188,9 +132,11 @@ function SaveCollection() collections = JSON.parse(localStorage.getItem("sets")); var newTabId; - chrome.tabs.create({}, function(tab) { newTabId = tab.id; }); - - chrome.tabs.remove(rawTabs.filter(i => !i.url.startsWith("chrome-extension") && !i.url.endsWith("TabsAside.html") && !i.pinned && i.id != newTabId).map(tab => tab.id)); + chrome.tabs.create({}, (tab) => + { + newTabId = tab.id; + chrome.tabs.remove(rawTabs.filter(i => !i.pinned && i.id != newTabId).map(tab => tab.id)); + }); UpdateTheme(); }); @@ -212,20 +158,23 @@ function RestoreCollection(collectionIndex, removeCollection) { url: i, active: false - } , function (createdTab) - { - chrome.storage.sync.get({ "loadOnRestore" : false }, values => { - if (!values.loadOnRestore) - chrome.tabs.onUpdated.addListener(function discarder(updatedTabId, changeInfo, updatedTab) { - if (updatedTabId === createdTab.id) { - chrome.tabs.onUpdated.removeListener(discarder); - if (!updatedTab.active) { - chrome.tabs.discard(updatedTabId); + }, + (createdTab) => + { + chrome.storage.sync.get({ "loadOnRestore" : false }, values => + { + if (!values.loadOnRestore) + chrome.tabs.onUpdated.addListener(function DiscardTab(updatedTabId, changeInfo, updatedTab) + { + if (updatedTabId === createdTab.id) { + chrome.tabs.onUpdated.removeListener(DiscardTab); + if (!updatedTab.active) { + chrome.tabs.discard(updatedTabId); + } } - } - }); + }); + }); }); - }); }); if (!removeCollection) @@ -237,24 +186,6 @@ function RestoreCollection(collectionIndex, removeCollection) UpdateTheme(); } -function AddTabsToFavorites(collectionIndex) -{ - alert("Adding to favorites"); - /*for (var i = 0; i < collections[collectionIndex].links.length; i++) - { - chrome.bookmarks.create( - { - title: collections[collectionIndex].titles[i], - url: collections[collectionIndex].links[i], - }); - }*/ -} - -function ShareTabs(collectionId) -{ - alert("Sharing"); -} - function RemoveTab(collectionIndex, tabIndex) { var set = collections[collectionIndex]; @@ -292,7 +223,7 @@ function RemoveTab(collectionIndex, tabIndex) var thumbnails = []; -function AppendThumbnail(tabId, cahngeInfo, tab) +function AppendThumbnail(tabId, tab) { if (!tab.active || !tab.url.startsWith("http")) return; @@ -302,7 +233,7 @@ function AppendThumbnail(tabId, cahngeInfo, tab) format: "jpeg", quality: 1 }, - function (dataUrl) + (dataUrl) => { if (!dataUrl) { @@ -325,4 +256,8 @@ function AppendThumbnail(tabId, cahngeInfo, tab) ); } -chrome.tabs.onUpdated.addListener(AppendThumbnail); +chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => +{ + if (changeInfo.status === "complete") + AppendThumbnail(tabId, tab) +}); \ No newline at end of file diff --git a/manifest.json b/manifest.json index 2f3e1a9..cd9aa41 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "Tabs Aside", - "version": "1.4", + "version": "1.5", "manifest_version": 2, "description": "Classic Microsoft Edge \"Tabs Aside\" feature for Chromium browsers", "author": "Michael \"XFox\" Gordeev",