Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
shahharsh87 committed Aug 21, 2017
0 parents commit e5c2ef7
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 0 deletions.
Binary file added Ironman-Mask-3-Old-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions background.js
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);
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions manifest.json
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://*/*"
]
}
18 changes: 18 additions & 0 deletions popup.html
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>

38 changes: 38 additions & 0 deletions popup.js
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);

0 comments on commit e5c2ef7

Please sign in to comment.