-
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 8194b4d
Showing
5 changed files
with
130 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,21 @@ | ||
console.log("hello"); | ||
function create_new_tab(url) { | ||
chrome.tabs.create( | ||
{ | ||
url: url, | ||
active: false, | ||
}, | ||
() => { | ||
console.log("success"); | ||
} | ||
); | ||
} | ||
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { | ||
if (request.url) { | ||
create_new_tab(request.url); | ||
console.log(sender.tab.url); | ||
console.log(request.url); | ||
|
||
sendResponse({ farewell: "success" }); | ||
} | ||
}); |
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,33 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "shortcut", | ||
"short_name": "Search", | ||
"description": "Searches for the selected text in the UrbanDictionary", | ||
"version": "0.0.1", | ||
|
||
|
||
"permissions": [ | ||
"contextMenus", | ||
"tabs", | ||
"activeTab" | ||
], | ||
"browser_action": { | ||
"default_popup": "popup.html" | ||
}, | ||
|
||
"icons": { | ||
"16": "assets/search.png" | ||
}, | ||
"content_scripts": [ { | ||
"matches": ["<all_urls>"], | ||
|
||
"js": ["popup.js"] | ||
} ], | ||
|
||
"background":{ | ||
"matches": ["<all_urls>"], | ||
"scripts": ["background.js"], | ||
"persistent":false | ||
|
||
} | ||
} |
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,11 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Shortcut Keys</title> | ||
<h1>Shortcut Keys</h1> | ||
<script src="popup.js"></script> | ||
</head> | ||
<body> | ||
<button id="changeColor">Check this page now!</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,65 @@ | ||
console.log("starting"); | ||
// !send the weblink json file before executing the document event listeners | ||
|
||
function printing_values() { | ||
var store = new Array(); | ||
let weblinks; | ||
var links = {}; | ||
weblinks = document.querySelectorAll(".yuRUbf"); | ||
var i; | ||
for (i of weblinks) { | ||
var x = i.querySelector("a").href; | ||
store.push(x); | ||
} | ||
var i; | ||
for (i = 0; i < weblinks.length; i++) { | ||
link_status = {}; // will have the weblink and opened status | ||
link_status["site"] = store[i].href; | ||
link_status["opened"] = false; | ||
links[i + 1] = link_status; | ||
} | ||
|
||
return links; | ||
} | ||
|
||
var weblinks = printing_values(); | ||
|
||
document.addEventListener("keydown", (event) => { | ||
var l = []; | ||
var time = []; | ||
console.log(event); | ||
if (event.key == "Control") { | ||
console.log("s"); | ||
l.push(event.code); | ||
time.push(event.timeStamp); | ||
|
||
document.addEventListener("keydown", (event) => { | ||
if (event.key == "Shift") { | ||
l.push(event.code); | ||
time.push(event.timeStamp); | ||
|
||
console.log("h"); | ||
|
||
document.addEventListener("keydown", (event) => { | ||
var x = event.code; | ||
var y = x.charAt(x.length - 1); | ||
y = parseInt(y); | ||
|
||
l.push(event.code); | ||
time.push(event.timeStamp); | ||
//console.log(l); | ||
/* TO DO: | ||
instead of opening and switching tab | ||
the new link be opened in new tab and current tab remains*/ | ||
console.log("hello"); | ||
chrome.runtime.sendMessage({ url: weblinks[y] }, function (response) { | ||
console.log(response.farewell); | ||
}); | ||
|
||
//window.open(weblinks[y], "_self"); | ||
//window.focus(); | ||
}); | ||
} | ||
}); | ||
} | ||
}); |