Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
`mint/` --> later rebuilt with [Mint](https://www.mint-lang.com/) just to try out something new

## What it looks like

Keeping the CSS simple...

<table>
<tr>
<td width=320><img src="./screenshot-1.png" width=270></td>
<td width=320><img src="./screenshot-2.png" width=270></td>
</tr>
</table>
6 changes: 3 additions & 3 deletions javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions mint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
53 changes: 24 additions & 29 deletions mint/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,37 @@ 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,
description: repoName,
}));
};

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 })
})
})
11 changes: 5 additions & 6 deletions mint/manifest.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{
"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"
},
"icons": {
"16": "icon.png"
},
"background": {
"persistent": false,
"scripts": ["background.js"]
"service_worker": "background.js"
},
"browser_action": {
"action": {
"default_popup": "index.html"
},
"permissions": [
"storage"
]
}
}
Binary file added screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.