-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (29 loc) · 961 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var windows = require("sdk/windows").browserWindows;
var { viewFor } = require("sdk/view/core");
var tabs = require("sdk/tabs");
var base64 = require("sdk/base64");
windows.on('open', function(window) {
console.log("A window was opened");
});
windows.on('close', function(window) {
console.log("A window was closed");
});
windows.on('activate', function(window) {
console.log("A window was activated");
viewFor(window).document.addEventListener('click', onclick);
});
windows.on('deactivate', function(window) {
console.log("A window was deactivated");
viewFor(window).document.removeEventListener('click', onclick);
});
function onclick(evt) {
var url = evt.target.href;
if (url && url.indexOf(".m3u") > 0) {
evt.preventDefault();
evt.stopPropagation();
console.log('hls URL found :' + url);
var playerUrl = 'player.html#' + base64.encode(url);
console.log('player URL:' + playerUrl);
tabs.open(playerUrl);
}
}