Skip to content

Commit

Permalink
Patching #404
Browse files Browse the repository at this point in the history
  • Loading branch information
MeoMix committed May 7, 2015
1 parent c9138d5 commit fc4cc11
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/js/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
define(['../common/requireConfig'], function() {
'use strict';

// Then, load all of the plugins needed by the background:
require(['background/plugins']);
// Opening background.html into its own tab causes the program to work incorrectly for a multitude of reasons.
// Prevent this by detecting the background being open outside of its default usage.
if (document.location.pathname === '/background.html' && window !== chrome.extension.getBackgroundPage()) {
window.close();
} else {
// Then, load all of the plugins needed by the background:
require(['background/plugins']);
}
});
2 changes: 2 additions & 0 deletions src/js/background/model/youTubePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@

// Emit errors so the foreground so can notify the user.
_onYouTubePlayerError: function(error) {
// TODO: YouTube's API emits a 'ReallyBad' error when it really wants to emit an 'NoPlayEmbedded2' error due to content restrictions.
// This only happens if I have the Referer set to a YouTube domain, though. Otherwise, it gives the correct error message.
// If the error is really bad then attempt to recover rather than reflecting the error throughout the program.
if (error.data === YouTubePlayerError.ReallyBad) {
this.preload();
Expand Down
1 change: 1 addition & 0 deletions src/js/background/view/youTubePlayerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
// Without a Referer - YouTube will reject most requests to play music.
_onChromeWebRequestBeforeSendHeaders: function(info) {
var refererRequestHeader = this._getHeader(info.requestHeaders, 'Referer');
// TODO: I think it would be prudent to set the referer to this.el.src
var referer = 'https://www.youtube.com/';

if (_.isUndefined(refererRequestHeader)) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/common/enum/youTubePlayerError.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
define({
None: -1,
InvalidParameter: 2,
// Undocumented error that YouTube throws when it breaks due to internet issues.
// Undocumented error that YouTube throws when it breaks due to internet issues and other unforseen circumstances.
ReallyBad: 5,
VideoNotFound: 100,
NoPlayEmbedded: 101,
Expand Down

0 comments on commit fc4cc11

Please sign in to comment.