Skip to content
This repository has been archived by the owner on Dec 12, 2019. It is now read-only.

Commit

Permalink
If path is not valid show a message, makes first usage easier
Browse files Browse the repository at this point in the history
  • Loading branch information
issue committed May 6, 2015
1 parent ca0bd3a commit f4e9d08
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
47 changes: 23 additions & 24 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ var button = require("sdk/ui/button/action").ActionButton({
//binary not found msg
var not_found_panel = panels.Panel({
contentURL: data.url("panel.html"),
width: 300,
height: 60
width: 280,
height: 70
});
//starting livestreamer msg
var launch_panel = panels.Panel({
Expand Down Expand Up @@ -69,21 +69,15 @@ function checkUrl(currentUrl) {
// display a context menu for twitch to launch a stream on rightclick
contextMenu.Item({
label: "Open with Livestreamer",
context:
[
contextMenu.PredicateContext(function(ctxnode){
context: [
contextMenu.PredicateContext(function(ctxnode){
return checkUrl(ctxnode.linkURL)
})
,
contextMenu.SelectorContext("a[href]")
]
,


}),
contextMenu.SelectorContext("a[href]")
],
contentScript: 'self.on("click", function(node, data){' +
'self.postMessage(node.href);' +
'});'
,
'});',


onMessage: function (streamURL) {
Expand Down Expand Up @@ -120,22 +114,27 @@ function buildArgs(streamURL, streamResolution) {
}

function runLivestreamer(args) {
var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
file.initWithPath(prefs.path);
if (file.exists() && prefs.path.indexOf("livestreamer") > -1) {
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
launch_panel.show({
position: button
});
process.init(file);
process.run(false, args, args.length);
if (prefs.path){
var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
file.initWithPath(prefs.path);
if (file.exists() && prefs.path.indexOf("livestreamer") > -1) {
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
launch_panel.show({
position: button
});
process.init(file);
process.run(false, args, args.length);
} else {
not_found_panel.show({
position: button
});
}
} else {
not_found_panel.show({
position: button
});
}
}

function buttonClicked() {
if (checkUrl(tabs.activeTab.url)) {
if (prefs.qualityselector) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "open livestreamer directly from the browser when on twitch, hitbox or youtube",
"author": "issue",
"license": "MPL 2.0",
"version": "1.2.2",
"version": "1.2.3",
"permissions": {
"private-browsing": true
},
Expand All @@ -14,7 +14,7 @@
"title": "Path to livestreamer",
"description": "Path to livestreamer executable",
"type": "string",
"value": "/usr/bin/livestreamer"
"value": ""
}, {
"name": "quality",
"title": "Stream quality",
Expand Down

0 comments on commit f4e9d08

Please sign in to comment.