-
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 e5c2ef7
Showing
6 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,13 @@ | ||
var callback = function(details) { | ||
alert(details.url); | ||
alert("wooo1"); | ||
if (details.url.indexof("=onechoice") == -1) { | ||
alert("Wohoooo2"); | ||
} | ||
}; | ||
|
||
var filter = {urls: ["<all_urls>"]}; | ||
var opt_extraInfoSpec = []; | ||
|
||
chrome.webRequest.onBeforeRequest.addListener( | ||
callback, filter, opt_extraInfoSpec); |
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,23 @@ | ||
{ | ||
"manifest_version": 2, | ||
|
||
"name": "One Choice!", | ||
"description": "One choice optimized for all cases.", | ||
"version": "1.0", | ||
"background": { | ||
"scripts": ["background.js"], | ||
"persistent": true | ||
}, | ||
"browser_action": { | ||
"default_icon": "icon.png", | ||
"default_popup": "popup.html", | ||
"default_title": "Once Choice!" | ||
}, | ||
"permissions": [ | ||
"tabs", | ||
"webRequest", | ||
"webRequestBlocking", | ||
"http://*/*", | ||
"https://*/*" | ||
] | ||
} |
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,18 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>OneChoice!</title> | ||
<style> | ||
input, text { | ||
width: 250px; | ||
} | ||
</style> | ||
<script src="popup.js"></script> | ||
</head> | ||
<body> | ||
<input type="text" id="searchKey" name="searchKey" size="50" placeholder="Search..." /> | ||
<input type="text" id="testing" size="50" /> | ||
<button id="onesearch" name="onesearch" type="button">Go!</button> | ||
</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,38 @@ | ||
function Get(the_url){ | ||
var Httpreq = new XMLHttpRequest(); // a new request | ||
Httpreq.open("GET", the_url, false); | ||
Httpreq.send(null); | ||
return Httpreq.responseText; | ||
} | ||
|
||
function onechoice() { | ||
var url = 'https://yaa25h3ffg.execute-api.us-east-1.amazonaws.com/test1/search?term='; | ||
var data = JSON.parse(Get(url+document.getElementById("searchKey").value)) | ||
/*chrome.windows.create({url: data['detailUrl']});*/ | ||
chrome.tabs.query({ active: true, lastFocusedWindow: true }, function (tab) { | ||
chrome.tabs.update(tab.id, {url:data['detailUrl']}); | ||
}); | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', function() { | ||
var goButton = document.getElementById("onesearch"); | ||
goButton.addEventListener("click", function() { | ||
onechoice() | ||
}, false); | ||
|
||
document.getElementById("searchKey") | ||
.addEventListener("keyup", function(event) { | ||
event.preventDefault(); | ||
if (event.keyCode == 13) { | ||
document.getElementById("onesearch").click(); | ||
} | ||
}); | ||
var filter = {urls: ["<all_urls>"] }; | ||
var opt_extraInfoSpec = []; | ||
chrome.webRequest.onBeforeRequest.addListener(function() { | ||
return {cancel: details.url.indexOf("onechoice") != -1}; | ||
document.getElementById("testing").value = details.url; | ||
document.getElementById("searchKey").value = "Kindle" | ||
document.getElementById("onesearch").click(); | ||
}, filter, opt_extraInfoSpec; | ||
}, false); |