diff --git a/README.md b/README.md index 7864c68..c29fe1a 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,24 @@ Omnibox extension to help you go straight to a GitHub repository. Activate the extension by typing "gh" followed by a space; you can then either -- Filter through your list of saved repositories +- Filter through your list of saved repositories and go +- Input the exact name of a repository and go - Hit space again to see the full list of saved repositories -- Enter the exact name of a repository -- Hit space and then enter to go to the target GitHub account itself +- Hit enter to go to the target GitHub account itself ## How it's built + `javascript/` --> initially built with vanilla JavaScript, HTML, CSS -`mint/` --> later rebuilt with [Mint](https://www.mint-lang.com/) just to try out something new \ No newline at end of file +`mint/` --> later rebuilt with [Mint](https://www.mint-lang.com/) just to try out something new + +## What it looks like + +Keeping the CSS simple... + + + + + + +
diff --git a/javascript/README.md b/javascript/README.md index 3a26818..68b6c08 100644 --- a/javascript/README.md +++ b/javascript/README.md @@ -9,7 +9,7 @@ Omnibox extension to help you go straight to a GitHub repository. Activate the extension by typing "gh" followed by a space; you can then either -- Filter through your list of saved repositories +- Filter through your list of saved repositories and go +- Input the exact name of a repository and go - Hit space again to see the full list of saved repositories -- Enter the exact name of a repository -- Hit space and then enter to go to the target GitHub account itself \ No newline at end of file +- Hit enter to go to the target GitHub account itself \ No newline at end of file diff --git a/mint/README.md b/mint/README.md index b5d0481..af07cd8 100644 --- a/mint/README.md +++ b/mint/README.md @@ -9,7 +9,7 @@ Omnibox extension to help you go straight to a GitHub repository. Activate the extension by typing "gh" followed by a space; you can then either -- Filter through your list of saved repositories +- Filter through your list of saved repositories and go +- Input the exact name of a repository and go - Hit space again to see the full list of saved repositories -- Enter the exact name of a repository -- Hit space and then enter to go to the target GitHub account itself +- Hit enter to go to the target GitHub account itself diff --git a/mint/js/background.js b/mint/js/background.js index da627e3..8af91c9 100644 --- a/mint/js/background.js +++ b/mint/js/background.js @@ -2,9 +2,6 @@ const BASE_URL = "https://github.com"; const STORAGE_PROFILE = "githubProfile"; const STORAGE_REPOS = "githubRepos"; -let storedGithubProfile; -let storedRepos = []; - const reposToSuggestions = (repos) => { return repos.map((repoName) => ({ content: repoName, @@ -12,32 +9,30 @@ const reposToSuggestions = (repos) => { })); }; -chrome.omnibox.onInputStarted.addListener(() => { - chrome.storage.sync.get([STORAGE_PROFILE, STORAGE_REPOS], (storage) => { - if (storage.githubProfile) { - storedGithubProfile = storage.githubProfile; - - if (storage.githubRepos) { - storedRepos = storage.githubRepos; - } - } - }); -}); - chrome.omnibox.onInputChanged.addListener((text, suggest) => { - if (!text || text.length === 0) { - const allSuggestions = reposToSuggestions(storedRepos); - return suggest(allSuggestions); - } - const filteredRepos = storedRepos.filter((repoName) => { - const searchTerm = text.toLowerCase(); - const doesMatch = repoName.toLowerCase().includes(searchTerm); - return doesMatch; - }); - const suggestions = reposToSuggestions(filteredRepos); - return suggest(suggestions); + chrome.storage.sync.get([STORAGE_REPOS], (storage) => { + const storedRepos = storage[STORAGE_REPOS]; + if (!text || text.length === 0) { + const allSuggestions = reposToSuggestions(storedRepos); + return suggest(allSuggestions); + } + const filteredRepos = storedRepos.filter((repoName) => { + const searchTerm = text.toLowerCase(); + const doesMatch = repoName.toLowerCase().includes(searchTerm); + return doesMatch; + }); + const suggestions = reposToSuggestions(filteredRepos); + return suggest(suggestions); + }) }); -chrome.omnibox.onInputEntered.addListener((text) => - chrome.tabs.update({ url: `${BASE_URL}/${storedGithubProfile}/${text}` }) -); +chrome.omnibox.onInputEntered.addListener((text) => { + chrome.storage.sync.get([STORAGE_PROFILE], (storage) => { + const storedGithubProfile = storage[STORAGE_PROFILE]; + let githubUrl = `${BASE_URL}/${storedGithubProfile}`; + if (text) { + githubUrl += `/${text}`; + } + chrome.tabs.update({ url: githubUrl }) + }) +}) diff --git a/mint/manifest.json b/mint/manifest.json index 39a62b0..fe667cd 100644 --- a/mint/manifest.json +++ b/mint/manifest.json @@ -1,8 +1,8 @@ { "name": "GitHubGo", - "version": "2.0.0", + "version": "2.0.1", "description": "A Github Chrome extension built with Mint", - "manifest_version": 2, + "manifest_version": 3, "omnibox": { "keyword": "gh" }, @@ -10,13 +10,12 @@ "16": "icon.png" }, "background": { - "persistent": false, - "scripts": ["background.js"] + "service_worker": "background.js" }, - "browser_action": { + "action": { "default_popup": "index.html" }, "permissions": [ "storage" ] -} +} \ No newline at end of file diff --git a/screenshot-1.png b/screenshot-1.png new file mode 100644 index 0000000..6449eb1 Binary files /dev/null and b/screenshot-1.png differ diff --git a/screenshot-2.png b/screenshot-2.png new file mode 100644 index 0000000..0aad443 Binary files /dev/null and b/screenshot-2.png differ