Edpuzzle aggressively reverts the playbackRate
of a <video>
element, so you can't simply change it to increase the speed. Thus, a more aggressive response is necessary to combat it.
Firstly, we get the <video>
element:
video = document.querySelector('video')
Then, we get the setter function for the playbackRate
property using Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'playbackRate').set
. It is called with the <video>
element as this
and with speed
as the new value. This way, the <video>
element is properly notified of the speed change by simulating assigning a value to playBackRate
directly (ie using =
).
Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'playbackRate').set.call(video, speed)
After that, to prevent Edpuzzle from changing it back, we make playbackRate
unwritable, so they can't simply set it:
Object.defineProperty(video, 'playbackRate', { writable: false })
Of course, if we can change the speed this way, so can Edpuzzle, so this might not work in the future.
my school blocked inspect element