Closed sxe closed 8 years ago
Ah i just noticed this addon works for other sites beside twitch as well. Right now the chat option would be opened on all sites.
I will change it to make it "twitch only".
ok, updated it again.
Greetings
Hi! Just tested the feature/twitch_chat branch. Few things:
{
"twitch.tv": {
"stream": "/(twitch)\\.tv/[A-z]+/g",
"irc": "irc.twitch.tv/#<stream_id>",
"http": "twitch.tv/<stream_id>chat?popout",
"port": "6667",
"notes": "Your password will be your OAuth string <http://help.twitch.tv/customer/portal/articles/1302780-twitch-irc>"
},
"ustream.tv": {
"stream": "/(ustream).tv/channel/[A-z]+/g",
"irc": "chat1.ustream.tv/#<stream_id>",
"http": "ustream.tv/socialstream/<stream_id>",
"port": "6667"
}
}
I'll take a look when I have time to make the openChat()
function modular.
Hi Julian, thx for the feedback.
Greetings
So since I can't push directly to this PR and if I fork your repo it will overwrite my fork I'll just post my diff changes.
The 2 main issues was open()
needed to be used instead of openDialog()
, not 100% why but the docs on windows/utlis is not great. Then I moved openChat()
call in the panel & context menu to the end of runLivestreamer()
function.`
At the top I added { open } = require('sdk/window/utils'),
:
const { Cc, Ci } = require("chrome");
var { ToggleButton } = require("sdk/ui/button/toggle"),
{ open } = require('sdk/window/utils'),
panels = require("sdk/panel"),
self = require("sdk/self"),
system = require("sdk/system"),
tabs = require("sdk/tabs"),
prefs = require("sdk/simple-prefs").prefs,
contextMenu = require("sdk/context-menu"),
locale = require("sdk/l10n").get;
I removed openChat()
from the panel & context menu and added it at the end of the runLivestreamer()
function as openChat(args[0]);
:
// Run Livestreamer
function runLivestreamer(args) {
var path,
file,
process;
// Notify
panel.width = 250;
panel.height = 90;
panel.port.emit("status", locale("status_lauching"));
panel.port.emit("loading", true);
// Get livestreamer path
path = getLivestreamerPath();
// Build file
file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
file.initWithPath(path);
// New child process
process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
process.init(file);
process.run(false, args, args.length);
// Open chat if selected
openChat(args[0]);
}
Then changed the openChat() function with:
// Open twitch chat
function openChat(url) {
if (prefs.chatselector == "none") {
return null;
}
// Check if it's a twitch link
// Chat only works for twitch so far
var reg = /(twitch)\.tv\/[A-z]+/g;
var twitch = reg.exec(url);
if (twitch[1] !== "twitch") {
return null;
}
if (prefs.chatselector == "popup") {
var chat = "/chat?popout=";
var url = url + chat;
var window = open('data:text/html,Loading...', {
name: 'Chat',
features: {
chrome: true,
centerscreen: true,
resizable: true,
scrollbars: false,
width: 400,
height: 550
}
});
window.addEventListener('load', function (win) {
window.location.href = url;
});
} else if (prefs.chatselector == "irc") {
var reg = /twitch\.tv\/([A-z]+)/g;
var name = reg.exec(url);
var url = "irc://irc.twitch.tv/#" + name[1];
var req = require("sdk/request").Request;
var fakeReq = req({
url: url
}).get();
}
Also open()
allows the OS's menu bar to be present so you can close the pop-up.
Hi Julian, i have to problems with your solution:
I will push my changes again to make sure we are talking about the same thing. ;)
Please have a look and let me know if that works. (It works perfectly on my system with the mentioned limitations.
aaaah, not sure why but that went over my head but If I understand you now you mean the message "Launching Livestreamer" instantly disappears because the pop-up window takes focus? If so you are correct, that will be tricky to fix without creating a global var.
Also what operating system are you on? I was Linux when using open()
and it worked like a charm yet when I switched to Windows open()
failed all together. openDialog()
works on Windows for me. I'll try your new commit on Linux and see if openDialog()
works. If not might have to create a bug report :(
"Launching Livestreamer" instantly disappears because the pop-up window takes focus?
Exactly
I am on Linux (Archlinux 64bit Firefox 38.0.5)
Hi there! Sorry for being so quiet in the last time, had a lot of RL stuff to do.
The chat feature sounds interesting. What I would prefer though, would be to have maybe an extra button in the quality selection box to open the chat. I don't want chat for all the channels I watch, and going through the addon preferences everytime is a pain imho.
Hi IsSuEat, that's kind of what julianrichen suggested with his 2. point.
I suggest the following.
I add a check box to the chat preference menu called "manual" (or something similar). If that box is checked two more entries are added to the "quality" panel with the ability to launch the chat (IRC or popup) an extra panel pops up to choose the chat. Combining it with the quality menu is a bit problematic cause you have to click twice. This way we have the auto launch chat functionality and a manual launch option.
*edit: We could also add check boxes for each chat type to the quality panel, so we just have one panel that pops up. I will play around with this idea and see what works better.
I will start to implement this, you guys can have a look then and decide if you like it.
The manual chat button could be under the "Launching livestreamer..." status message to notify the user that the streaming is launching but that they can also open the chat if they wish. Would avoid another step (and panel).
Also Open in Livestreamer just got it's 2.0 version approved in the addon repo :)
I'm gonna close this. If anyone wants to do this, I will reopen it :)
Hi there, i have added the possibility to open the twitch chat when a stream is launched. There is a new entry in the preferences menu for that. You can either use a browser popup or a native irc client to start the chat (or disable it completely "default").
Please have a look and let me know what you think. Works great on my system so far.
Greetings, Andy