-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7892112
Showing
6 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## URL Alias Chrome Extension | ||
|
||
Set aliases for your frequently visited sites and use them just from the address bar | ||
|
||
### Examples | ||
- Add alias and corresponding URL from the extension's popup. | ||
- Type in ```"hb" + TAB``` in address bar. | ||
- Type your alias, press ```ENTER```. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Background script | ||
*/ | ||
|
||
// Empty alias to URL mapping | ||
var aliasToURLMap = {} | ||
var aliasToURLParsed = JSON.stringify(aliasToURLMap); | ||
|
||
chrome.runtime.onInstalled.addListener(() => { | ||
chrome.storage.sync.set({ aliasToURLParsed }); | ||
console.log("URL map value set"); | ||
}); | ||
|
||
chrome.omnibox.onInputEntered.addListener((alias) => { | ||
console.log("Alias received: ", alias); | ||
chrome.storage.sync.get("aliasToURLParsed", ({ aliasToURLParsed }) => { | ||
var aliasToURLMap = JSON.parse(aliasToURLParsed); | ||
chrome.tabs.create({ url: aliasToURLMap[alias] }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "URL Alias", | ||
"description": "Extension to use aliases for URLs", | ||
"version": "1.0", | ||
"manifest_version": 3, | ||
"background": { | ||
"service_worker": "background.js" | ||
}, | ||
"permissions": ["storage", "tabs"], | ||
"omnibox": { | ||
"keyword": "hb" | ||
}, | ||
"action": { | ||
"default_popup": "popup.html" | ||
}, | ||
"author": "Hrishikesh Bawane" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<div> | ||
<label for="aliasInput">Alias</label> | ||
<input id="aliasInput"> | ||
<br /> | ||
<label for="urlInput">URL</label> | ||
<input id="urlInput"> | ||
<br /> | ||
<button id="saveAlias">Save</button> | ||
</div> | ||
<div> | ||
<p id="prevAliases"></p> | ||
</div> | ||
<script src="popup.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Action script for extension popup | ||
*/ | ||
|
||
var aliasToUrlMap; | ||
|
||
window.onload = setPrevAliases; | ||
|
||
document.getElementById("saveAlias").addEventListener("click", saveNewAlias); | ||
|
||
function setPrevAliases() { | ||
chrome.storage.sync.get("aliasToURLParsed", ({aliasToURLParsed}) => { | ||
aliasToUrlMap = JSON.parse(aliasToURLParsed); | ||
var displayStr = ""; | ||
for (var alias in aliasToUrlMap) | ||
{ | ||
displayStr += alias + ": " + aliasToUrlMap[alias]; | ||
displayStr += "<br />"; | ||
} | ||
document.getElementById("prevAliases").innerHTML = displayStr; | ||
}); | ||
} | ||
|
||
function saveNewAlias() { | ||
var newAlias = document.getElementById("aliasInput").value; | ||
var newUrl = document.getElementById("urlInput").value; | ||
aliasToUrlMap[newAlias] = newUrl; | ||
var aliasToURLParsed = JSON.stringify(aliasToUrlMap); | ||
chrome.storage.sync.set({ aliasToURLParsed }); | ||
setPrevAliases(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
button { | ||
height: 30px; | ||
width: 100px; | ||
margin: 10px; | ||
background-color: lightgreen; | ||
} | ||
|
||
input { | ||
height: 30px; | ||
width: auto; | ||
margin: 10px; | ||
} | ||
|
||
label { | ||
font-weight: bold; | ||
margin: 10px; | ||
} |