diff --git a/bin/amo/tab_search-1.0.8-an+fx.xpi b/bin/amo/tab_search-1.0.8-an+fx.xpi new file mode 100644 index 0000000..ca29c71 Binary files /dev/null and b/bin/amo/tab_search-1.0.8-an+fx.xpi differ diff --git a/bin/unlisted/tab_search-1.0.0-an+fx.xpi b/bin/unlisted/tab_search-1.0.0-an+fx.xpi new file mode 100644 index 0000000..6b194b6 Binary files /dev/null and b/bin/unlisted/tab_search-1.0.0-an+fx.xpi differ diff --git a/bin/unlisted/tab_search-1.0.2-an+fx.xpi b/bin/unlisted/tab_search-1.0.2-an+fx.xpi new file mode 100644 index 0000000..aa48c51 Binary files /dev/null and b/bin/unlisted/tab_search-1.0.2-an+fx.xpi differ diff --git a/bin/unlisted/tab_search-1.0.4-an+fx.xpi b/bin/unlisted/tab_search-1.0.4-an+fx.xpi new file mode 100644 index 0000000..1a950ae Binary files /dev/null and b/bin/unlisted/tab_search-1.0.4-an+fx.xpi differ diff --git a/bin/unlisted/tab_search-1.0.6-an+fx.xpi b/bin/unlisted/tab_search-1.0.6-an+fx.xpi new file mode 100644 index 0000000..d535d9f Binary files /dev/null and b/bin/unlisted/tab_search-1.0.6-an+fx.xpi differ diff --git a/src/css/tabsSearch.css b/src/css/tabsSearch.css new file mode 100644 index 0000000..35a9577 --- /dev/null +++ b/src/css/tabsSearch.css @@ -0,0 +1,51 @@ +body { background: rgb(255,255,255); width: 18em; overflow-x: hidden; } +#listZone { margin-top: 0.5em; } + +#toFind { + width: 95%; + background: rgb(255,255,255); + color: rgb(0,0,0); + border-style: solid; + border-color: rgb(0, 0, 0); + text-align: center; + padding: 0.5em; +} +#errorZone { + border-color: rgb(0,0,0); + border-style: dotted; + color: red; + margin-top: 2em; + padding-top: 0.5em; + padding-bottom: 0.5em; + text-align: center; +} + +.box:hover { background-color: #3EA724; } +.box { + display: block; + cursor: pointer; + background-color: #444444; + border-radius: 5px; + padding: 20px; + width: 120px; + height: 120px; + overflow: hidden; + margin: 0 auto; + text-align: center; +} + +.thumbImg { + width: 64px; + height: 64px; + margin-left: auto; + margin-right: auto; +} + +.title { + float: left; + clear: left; + height: 55px; + max-width: 120px; + overflow: hidden; + color: #ffffff; +} diff --git a/src/icons/tabsSearch_48.png b/src/icons/tabsSearch_48.png new file mode 100644 index 0000000..fa38ac2 Binary files /dev/null and b/src/icons/tabsSearch_48.png differ diff --git a/src/icons/tabsSearch_96.png b/src/icons/tabsSearch_96.png new file mode 100644 index 0000000..5a9ad72 Binary files /dev/null and b/src/icons/tabsSearch_96.png differ diff --git a/src/manifest.json b/src/manifest.json new file mode 100644 index 0000000..e5c27ff --- /dev/null +++ b/src/manifest.json @@ -0,0 +1,29 @@ +{ + "manifest_version": 2, + "name": "Tab Search", + "version": "1.0.8", + "description": "Search Tabs and switch to them quickly.", + + "applications": { + "gecko": { + "id": "tabsSearch@itdominator.com" + } + }, + + "icons": { + "48": "icons/tabsSearch_48.png", + "96": "icons/tabsSearch_96.png" + }, + + "permissions": [ + "activeTab", + "tabs" + ], + + "browser_action": { + "default_icon": "icons/tabsSearch_48.png", + "default_title": "Tab Search", + "default_popup": "pages/tabsSearch.html" + } + +} diff --git a/src/pages/tabsSearch.html b/src/pages/tabsSearch.html new file mode 100755 index 0000000..26c0d57 --- /dev/null +++ b/src/pages/tabsSearch.html @@ -0,0 +1,15 @@ + + + + + + + + + +
+ + + + + diff --git a/src/scripts/tabsSearch.js b/src/scripts/tabsSearch.js new file mode 100644 index 0000000..91f11b2 --- /dev/null +++ b/src/scripts/tabsSearch.js @@ -0,0 +1,81 @@ +const toFind = document.getElementById("toFind"); +const tabQuery = browser.tabs.query({currentWindow: true}); +const errHandler = document.getElementById("errorZone"); +const listZone = document.getElementById("listZone"); +const notFoundText = document.createTextNode("Search not found..."); + +document.getElementById("toFind").onkeypress = function(e){ + searchTabs(); +} + +document.addEventListener("click", (e) => { + if (e.target.id != "toFind" && e.target.id != "listZone" ) { + if (e.target.tagName == "IMG") { + var parent = e.target.parentNode; + loadSelTab(parseInt(parent.id)); + } else { + loadSelTab(parseInt(e.target.id)); + } + } +}); + +function logTabs(tabs) { + var selection = []; + + clearNodes(listZone); + if (toFind.value != "") { + for (let tab of tabs) { + var title = tab.title; + if (title.toLowerCase().includes(toFind.value.toLowerCase())) { + selection.push(tab); + } + } + if (selection.length > 1) { + for (let sel of selection) { + icon = document.createElement("DIV"); + thumbnail = document.createElement("IMG"); + title = document.createElement("P"); + lineBreak = document.createElement("BR"); + titleText = document.createTextNode(sel.title); + + icon.id = sel.id; + icon.className = "box"; + thumbnail.className = "thumbImg"; + thumbnail.src = sel.favIconUrl; + title.className = "title"; + + icon.appendChild(thumbnail); + icon.appendChild(title); + title.appendChild(titleText); + listZone.appendChild(icon); + listZone.appendChild(lineBreak); + } + errHandler.style.display = "none"; + clearNodes(errHandler); + } else { + if (selection[0] != undefined) { + errHandler.style.display = "none"; + clearNodes(errHandler); + loadSelTab(selection[0].id); + } else { + errHandler.style.display = "block"; + errHandler.appendChild(notFoundText); + } + } + } +} + +function loadSelTab(id) { + browser.tabs.update(id, { + active: true + }); +} + +function clearNodes(targetNode) { + while (targetNode.firstChild) { + targetNode.removeChild(targetNode.firstChild); + } +} + +function searchTabs() { tabQuery.then(logTabs, onError); } +function onError(error) { console.log(`Error: ${error}`); }