Skip to content

Commit

Permalink
fix workers list handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lejenome committed Nov 26, 2014
1 parent 9dc2314 commit 612ea2a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
41 changes: 22 additions & 19 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
/* jshint esnext:true, node:true*/
"use strict";
var data = require("sdk/self").data;
const {
Cc, Ci, Cr
} = require("chrome");
const {
add, remove
} = require("sdk/util/array");
const data = require("sdk/self").data;
const pageMod = require("sdk/page-mod");
const events = require("sdk/system/events");
const utils = require("sdk/window/utils");
var prefs = require("sdk/simple-prefs").prefs;
var pageMod = require("sdk/page-mod");
// object of current workers
var workers = {};
// list of current workers
const workers = [];
pageMod.PageMod({
include: "*.www.youtube.com",
contentStyleFile: data.url("video-js.css"),
Expand All @@ -21,7 +29,11 @@ pageMod.PageMod({
preferredQuality: prefs.preferredQuality,
volume: prefs.volume
});
workers[worker.tab.id] = worker;
add(workers, worker);
worker.on("detach", function(e) {
remove(workers, this);

});
}
});

Expand All @@ -36,22 +48,13 @@ require("sdk/simple-prefs").on("", function prefChangeHandler(pref) {
});

function workersPrefHandler(pref) {
for (var worker in workers)
if (workers.hasOwnProperty(worker))
if (!workers[worker].tab)
delete workers[worker];
else
workers[worker].port.emit("prefChanged", {
name: pref,
value: prefs[pref]
});
for (let worker of workers)
worker.port.emit("prefChanged", {
name: pref,
value: prefs[pref]
});
}
const {
Cc, Ci, Cr
} = require("chrome");

var events = require("sdk/system/events");
var utils = require("sdk/window/utils");
var YOUTUBE_FLASH_REGEX = /https?:\/\/(www.)?youtube.com\/v\/([^#?\/]*)/;
var YT_BIN_REGEX = /https:\/\/s.ytimg.com\/yts\/jsbin\/[^\/]*\/base.js/;
var YT_PLAYER_REGEX = /https?:\/\/s.ytimg.com\/yts\/jsbin\/[^\/]*\/html5player.js/;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "Moez Bouhlel <[email protected]> (http://lejenome.github.io/)",
"homepage": "https://github.com/lejenome/youtube-html5-player",
"license": "MPL 2.0",
"version": "0.1.3",
"version": "0.1.4",
"preferences": [
{
"name": "preferredCodec",
Expand Down
Binary file modified youtube-video-player.xpi
Binary file not shown.

0 comments on commit 612ea2a

Please sign in to comment.