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
|
|
@ -4,3 +4,19 @@ window.GoogleDrivePlayer = class GoogleDrivePlayer extends VideoJSPlayer
|
|||
return new GoogleDrivePlayer(data)
|
||||
|
||||
super(data)
|
||||
|
||||
load: (data) ->
|
||||
if typeof window.getGoogleDriveMetadata is 'function'
|
||||
window.getGoogleDriveMetadata(data.id, (error, metadata) =>
|
||||
if error
|
||||
console.error(error)
|
||||
alertBox = window.document.createElement('div')
|
||||
alertBox.className = 'alert alert-danger'
|
||||
alertBox.textContent = error.message
|
||||
document.getElementById('ytapiplayer').appendChild(alertBox)
|
||||
else
|
||||
data.meta.direct = metadata.videoMap
|
||||
super(data)
|
||||
)
|
||||
else
|
||||
super(data)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ window.loadMediaPlayer = (data) ->
|
|||
else if data.type is 'gd'
|
||||
try
|
||||
if data.meta.html5hack or window.hasDriveUserscript
|
||||
window.PLAYER = new window.GoogleDrivePlayer(data)
|
||||
window.PLAYER = new GoogleDrivePlayer(data)
|
||||
else
|
||||
window.PLAYER = new GoogleDriveYouTubePlayer(data)
|
||||
catch e
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ window.VideoJSPlayer = class VideoJSPlayer extends Player
|
|||
if not (this instanceof VideoJSPlayer)
|
||||
return new VideoJSPlayer(data)
|
||||
|
||||
@setMediaProperties(data)
|
||||
@loadPlayer(data)
|
||||
@load(data)
|
||||
|
||||
loadPlayer: (data) ->
|
||||
waitUntilDefined(window, 'videojs', =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue