Add workaround for GM sandbox and refactor userscript a bit
This commit is contained in:
parent
8d3b2e59df
commit
578d3fbb23
5 changed files with 155 additions and 62 deletions
|
|
@ -503,8 +503,7 @@
|
|||
if (!(this instanceof VideoJSPlayer)) {
|
||||
return new VideoJSPlayer(data);
|
||||
}
|
||||
this.setMediaProperties(data);
|
||||
this.loadPlayer(data);
|
||||
this.load(data);
|
||||
}
|
||||
|
||||
VideoJSPlayer.prototype.loadPlayer = function(data) {
|
||||
|
|
@ -676,6 +675,28 @@
|
|||
GoogleDrivePlayer.__super__.constructor.call(this, data);
|
||||
}
|
||||
|
||||
GoogleDrivePlayer.prototype.load = function(data) {
|
||||
if (typeof window.getGoogleDriveMetadata === 'function') {
|
||||
return window.getGoogleDriveMetadata(data.id, (function(_this) {
|
||||
return function(error, metadata) {
|
||||
var alertBox;
|
||||
if (error) {
|
||||
console.error(error);
|
||||
alertBox = window.document.createElement('div');
|
||||
alertBox.className = 'alert alert-danger';
|
||||
alertBox.textContent = error.message;
|
||||
return document.getElementById('ytapiplayer').appendChild(alertBox);
|
||||
} else {
|
||||
data.meta.direct = metadata.videoMap;
|
||||
return GoogleDrivePlayer.__super__.load.call(_this, data);
|
||||
}
|
||||
};
|
||||
})(this));
|
||||
} else {
|
||||
return GoogleDrivePlayer.__super__.load.call(this, data);
|
||||
}
|
||||
};
|
||||
|
||||
return GoogleDrivePlayer;
|
||||
|
||||
})(VideoJSPlayer);
|
||||
|
|
@ -1359,7 +1380,7 @@
|
|||
} else if (data.type === 'gd') {
|
||||
try {
|
||||
if (data.meta.html5hack || window.hasDriveUserscript) {
|
||||
return window.PLAYER = new window.GoogleDrivePlayer(data);
|
||||
return window.PLAYER = new GoogleDrivePlayer(data);
|
||||
} else {
|
||||
return window.PLAYER = new GoogleDriveYouTubePlayer(data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue