├── LICENSE ├── README.md ├── go-to-random-tab.js ├── icons ├── shuffle-48.png ├── shuffle-96.png ├── shuffle-dark-16.png ├── shuffle-dark-32.png ├── shuffle-dark-64.png ├── shuffle-light-16.png ├── shuffle-light-32.png └── shuffle-light-64.png └── manifest.json /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Mikkel Hoegh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # “Go to random tab” browser extension 2 | 3 | Simple browser extension, provides a button to to switch to a random, open tab. 4 | 5 | Compatible with [Firefox][], [Chrome][], and [Opera][], and 6 | theoretically, all browsers supporting the Web Extensions API. 7 | 8 | Uses [Bootstrap Icons][]. 9 | 10 | ## Development 11 | 12 | To publish a new version of the extension, package the extension in a zip file 13 | with this command: 14 | 15 | ```sh 16 | git archive --format zip --output ./go-to-random-tab.zip master 17 | ``` 18 | 19 | [Bootstrap Icons]: https://icons.getbootstrap.com/ 20 | [Chrome]: https://google.com/chrome/ 21 | [Firefox]: https://mozilla.org/firefox 22 | [Opera]: http://www.opera.com/ 23 | -------------------------------------------------------------------------------- /go-to-random-tab.js: -------------------------------------------------------------------------------- 1 | /* global chrome */ 2 | 'use strict'; 3 | 4 | // Filtering options for tabs.query(). 5 | const tabFilter = { 6 | // Avoid switching to the current tab. 7 | active: false, 8 | currentWindow: true, 9 | }; 10 | 11 | function goToRandomTab() { 12 | chrome.tabs.query(tabFilter, function (tabs) { 13 | // If we need at least one other tabs to switch anywhere. 14 | if (tabs.length < 1) { 15 | return; 16 | } 17 | 18 | // Try switching tabs up to three times. 19 | for (let i = 0; i < 3; i += 1) { 20 | let newTabIndex = Math.floor(Math.random() * tabs.length); 21 | 22 | if (tabs[newTabIndex]) { 23 | chrome.tabs.update(tabs[newTabIndex].id, { active: true }); 24 | break; 25 | } 26 | } 27 | }); 28 | } 29 | 30 | chrome.browserAction.onClicked.addListener(function (tab) { 31 | goToRandomTab(); 32 | }); 33 | 34 | chrome.commands.onCommand.addListener(function (command) { 35 | if (command == 'go-to-random-tab') { 36 | goToRandomTab(); 37 | } 38 | }); 39 | -------------------------------------------------------------------------------- /icons/shuffle-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikl/browser-go-to-random-tab/e7839d0e14212687c818541a7593ad77e87d5ca1/icons/shuffle-48.png -------------------------------------------------------------------------------- /icons/shuffle-96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikl/browser-go-to-random-tab/e7839d0e14212687c818541a7593ad77e87d5ca1/icons/shuffle-96.png -------------------------------------------------------------------------------- /icons/shuffle-dark-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikl/browser-go-to-random-tab/e7839d0e14212687c818541a7593ad77e87d5ca1/icons/shuffle-dark-16.png -------------------------------------------------------------------------------- /icons/shuffle-dark-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikl/browser-go-to-random-tab/e7839d0e14212687c818541a7593ad77e87d5ca1/icons/shuffle-dark-32.png -------------------------------------------------------------------------------- /icons/shuffle-dark-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikl/browser-go-to-random-tab/e7839d0e14212687c818541a7593ad77e87d5ca1/icons/shuffle-dark-64.png -------------------------------------------------------------------------------- /icons/shuffle-light-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikl/browser-go-to-random-tab/e7839d0e14212687c818541a7593ad77e87d5ca1/icons/shuffle-light-16.png -------------------------------------------------------------------------------- /icons/shuffle-light-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikl/browser-go-to-random-tab/e7839d0e14212687c818541a7593ad77e87d5ca1/icons/shuffle-light-32.png -------------------------------------------------------------------------------- /icons/shuffle-light-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikl/browser-go-to-random-tab/e7839d0e14212687c818541a7593ad77e87d5ca1/icons/shuffle-light-64.png -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "Go to random tab", 4 | "version": "2.1.1", 5 | "description": "A simple button to go to a random open tab.", 6 | "homepage_url": "https://github.com/mikl/browser-go-to-random-tab", 7 | "icons": { 8 | "48": "icons/shuffle-48.png", 9 | "96": "icons/shuffle-96.png" 10 | }, 11 | "browser_specific_settings": { 12 | "gecko": { 13 | "id": "jid1-3vuPf16zAtrlFA@jetpack" 14 | } 15 | }, 16 | "permissions": ["tabs"], 17 | "browser_action": { 18 | "browser_style": true, 19 | "default_area": "tabstrip", 20 | "default_icon": { 21 | "16": "icons/shuffle-dark-16.png", 22 | "32": "icons/shuffle-dark-32.png", 23 | "64": "icons/shuffle-dark-64.png" 24 | }, 25 | "default_title": "Go to random tab", 26 | "theme_icons": [ 27 | { 28 | "light": "icons/shuffle-light-16.png", 29 | "dark": "icons/shuffle-dark-16.png", 30 | "size": 16 31 | }, 32 | { 33 | "light": "icons/shuffle-light-32.png", 34 | "dark": "icons/shuffle-dark-32.png", 35 | "size": 32 36 | }, 37 | { 38 | "light": "icons/shuffle-light-64.png", 39 | "dark": "icons/shuffle-dark-64.png", 40 | "size": 64 41 | } 42 | ] 43 | }, 44 | "background": { 45 | "scripts": ["go-to-random-tab.js"], 46 | "persistent": false 47 | }, 48 | "commands": { 49 | "go-to-random-tab": { 50 | "suggested_key": { 51 | "default": "Alt+Shift+R" 52 | }, 53 | "description": "Switch to a random open tab." 54 | } 55 | } 56 | } 57 | --------------------------------------------------------------------------------