Skip to content

Commit 41e097e

Browse files
committed
Initial commit
1 parent 79f30ee commit 41e097e

File tree

61 files changed

+91656
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+91656
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.exe

chrome/.idea/chrome.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chrome/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chrome/.idea/workspace.xml

Lines changed: 236 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chrome/background.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
function start(url) {
3+
chrome.storage.sync.get({path: "", arguments: []}, function(items) {
4+
var port = chrome.runtime.connectNative('fmatos.chromeapplicationlauncher');
5+
var args = "";
6+
items.arguments.forEach(function(arg){
7+
args += arg + " ";
8+
});
9+
args = args.replace("$url",url)
10+
console.log({exec: items.path, args: args});
11+
port.postMessage({exec: items.path, args: args});
12+
});
13+
}
14+
15+
chrome.browserAction.onClicked.addListener(function(tab){
16+
chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, function (tabs) {
17+
start(tabs[0].url);
18+
});
19+
});

chrome/chrome.zip

6.43 KB
Binary file not shown.

chrome/icon.png

1.73 KB
Loading

chrome/manifest.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"manifest_version": 2,
3+
4+
"name": "Application Launcher",
5+
"description": "Quickly run applications with current tab URL as parameter!",
6+
"version": "0.0.0.2",
7+
8+
"options_ui": {
9+
"page": "options.html",
10+
"chrome_style": true
11+
},
12+
"browser_action": {
13+
"default_icon": "icon.png"
14+
},
15+
"permissions": [
16+
"activeTab",
17+
"storage",
18+
"nativeMessaging"
19+
],
20+
"background": {
21+
"scripts": ["background.js"]
22+
}
23+
}

chrome/options.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>My Test Extension Options</title>
5+
<style>
6+
body: { padding: 10px; }
7+
</style>
8+
</head>
9+
10+
<body>
11+
<label>
12+
Executable path
13+
<input id="path" type="text" style="width:300px">
14+
</label>
15+
<br/><br/>
16+
<label>
17+
Arguments ($url is active tab url)
18+
</label>
19+
<div id="args">
20+
</div>
21+
<button id="add">Add Argument</button><br/>
22+
<button id="save">Save</button>
23+
<div id="status"></div>
24+
<script src="options.js"></script>
25+
</body>
26+
</html>

chrome/options.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
function save_options() {
2+
var els = document.getElementsByClassName("argument");
3+
var args = [];
4+
for(var i=0; i< els.length; i++){
5+
var value = els.item(i).value;
6+
if(value !== "") args.push(value);
7+
}
8+
chrome.storage.sync.set({
9+
path: document.getElementById('path').value,
10+
arguments: args
11+
}, function () {
12+
var status = document.getElementById('status');
13+
status.textContent = 'Options saved.';
14+
setTimeout(function () {
15+
status.textContent = '';
16+
}, 750);
17+
});
18+
}
19+
20+
function restore_options() {
21+
chrome.storage.sync.get({path: "", arguments: []}, function (items) {
22+
document.getElementById('path').value = items.path;
23+
items.arguments.forEach(function(arg){
24+
if(arg !== "") add_argument(arg);
25+
})
26+
});
27+
}
28+
29+
function add_argument(value) {
30+
var root = document.createElement('div');
31+
var input = document.createElement('input');
32+
input.style.width = "300px";
33+
input.type = "text";
34+
input.className = "argument";
35+
if(typeof value === "string"){
36+
input.value = value;
37+
}
38+
root.appendChild(input);
39+
document.getElementById('args').appendChild(root)
40+
}
41+
42+
document.addEventListener('DOMContentLoaded', restore_options);
43+
document.getElementById('save').addEventListener('click', save_options);
44+
document.getElementById('add').addEventListener('click', add_argument);

0 commit comments

Comments
 (0)