diff --git a/README.md b/README.md new file mode 100644 index 0000000..2d9c8d9 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# Alt Tab Page +Alt Tab Page allows the user to select their preferred load page for new tabs and defaults to Google's when not in use. + +# Download +https://addons.mozilla.org/en-US/firefox/addon/alt-tab-page/ + +# Version: 1.0.0 +Initial release. + +# Images +![1 settings](images/pic1.png) +![2 icon logo](images/pic1.png) diff --git a/altTabPage.svg b/altTabPage.svg new file mode 100644 index 0000000..d18e786 --- /dev/null +++ b/altTabPage.svg @@ -0,0 +1,171 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + T + A + L + + diff --git a/images/pic1.png b/images/pic1.png new file mode 100644 index 0000000..b739359 Binary files /dev/null and b/images/pic1.png differ diff --git a/images/pic2.png b/images/pic2.png new file mode 100644 index 0000000..8a9f215 Binary files /dev/null and b/images/pic2.png differ diff --git a/src/icons/altTabPage_48x48.png b/src/icons/altTabPage_48x48.png new file mode 100644 index 0000000..c4a8e18 Binary files /dev/null and b/src/icons/altTabPage_48x48.png differ diff --git a/src/icons/altTabPage_96x96.png b/src/icons/altTabPage_96x96.png new file mode 100644 index 0000000..8a9f215 Binary files /dev/null and b/src/icons/altTabPage_96x96.png differ diff --git a/src/manifest.json b/src/manifest.json new file mode 100644 index 0000000..9a81c87 --- /dev/null +++ b/src/manifest.json @@ -0,0 +1,22 @@ +{ + "manifest_version": 2, + "name": "Alt Tab Page", + "version": "1.0.0", + "description": "Alt Tab Page helps set the preferred load page for new tabs.", + + "applications": { + "gecko": { + "id": "altTabPage@itdominator.com", + "strict_min_version": "54.0" + } + }, + + "icons": { + "48": "icons/altTabPage_48x48.png", + "96": "icons/altTabPage_96x96.png" + }, + + "permissions": [ "storage" ], + "options_ui": { "page": "pages/options.html" }, + "chrome_url_overrides": { "newtab": "pages/newTab.html" } +} diff --git a/src/pages/newTab.html b/src/pages/newTab.html new file mode 100644 index 0000000..fe5ff19 --- /dev/null +++ b/src/pages/newTab.html @@ -0,0 +1,10 @@ + + + + New Tab + + + + + + diff --git a/src/pages/options.html b/src/pages/options.html new file mode 100755 index 0000000..8263590 --- /dev/null +++ b/src/pages/options.html @@ -0,0 +1,26 @@ + + + + Alt Tab Page Settings + + + + + + +

+ Alt Tab Page allows the user to select their preferred load page for new tabs and defaults to Google's when not in use. +

+ + + + +

+
+ + + + diff --git a/src/scripts/altTabPageSettings.js b/src/scripts/altTabPageSettings.js new file mode 100644 index 0000000..eb74ba3 --- /dev/null +++ b/src/scripts/altTabPageSettings.js @@ -0,0 +1,44 @@ +// Declare variables. +const browserStorage = browser.storage.local; +const tabPgInput = document.querySelector("#tabPageToLoad"); +const saveBttn = document.querySelector("#saveButtonAction"); +const delBttn = document.querySelector("#delButtonAction"); + + +/* Asign signal handaling in settings page. */ +// Save desired url.... +saveBttn.addEventListener('click', () => { + var urlLink = tabPgInput.value; + urlLink = (urlLink.match(/(localhost)\b/)) ? urlLink.replace("localhost", "127.0.0.1") : urlLink; + urlLink = (urlLink.match(/^(http:\/\/|https:\/\/)/)) ? urlLink : "http://" + urlLink; + + browserStorage.clear(); + browserStorage.set({ userSelectedTabPage : urlLink }); + + tabPgInput.value = urlLink; + console.log("Saved Alt Tab Page: " + urlLink); +}); + +// Delete desired url and set Default marker.... +delBttn.addEventListener('click', () => { + browserStorage.clear(); + tabPgInput.value = "Default"; + console.log("Deleted Alt Tab Page..."); +}); + +// On start load from settings +function loadOnStart(restoredSettings) { + var homeTabURL = restoredSettings.userSelectedTabPage; + + console.log("Trying to load settings if any..."); + if (homeTabURL !== "Default" && homeTabURL !== undefined) { + tabPgInput.value = homeTabURL + } else { + tabPgInput.value = "Default"; + } +} + +function onError(e) { console.error(e); } + + +browserStorage.get().then(loadOnStart, onError); diff --git a/src/scripts/loadNewPage.js b/src/scripts/loadNewPage.js new file mode 100644 index 0000000..448583a --- /dev/null +++ b/src/scripts/loadNewPage.js @@ -0,0 +1,21 @@ +function redirectToPreferedHome() { + var tabPgSettings = browser.storage.local.get(); + tabPgSettings.then(finishLoad, onError); +} + +function finishLoad(toLoadSettings) { + var loadSelectedPage = browser.tabs; + var pageToLoad = toLoadSettings.userSelectedTabPage; + + console.log("Trying to load settings if any..."); + if (pageToLoad !== "Default" && pageToLoad !== undefined) { + loadSelectedPage.update({url: pageToLoad}); + } else { + loadSelectedPage.update({url: "https://www.google.com/"}); + } +} + +function onError(error) { console.log(`Error: ${error}`); } + + +redirectToPreferedHome();