Skip to content

Instantly share code, notes, and snippets.

@SheepTester
Created May 4, 2020 19:35
Show Gist options
  • Save SheepTester/a5009c402d58117b167049faa274de52 to your computer and use it in GitHub Desktop.
Save SheepTester/a5009c402d58117b167049faa274de52 to your computer and use it in GitHub Desktop.
Change speed of Edpuzzle video

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.

// Paste the following code in the console (right click > inspect element, then click on the Console tab) on the Edpuzzle page
speed = 2 // Change this to the speed (eg 2 for 2x speed)
video = document.querySelector('video')
Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'playbackRate').set.call(video, speed)
Object.defineProperty(video, 'playbackRate', { writable: false })
@achow0
Copy link

achow0 commented Mar 25, 2021

I'm getting error Uncaught TypeError: Illegal invocation at <anonymous>:3:81. How to fix this?

@SheepTester
Copy link
Author

@achow0 That might be because video is null. This might be because the Edpuzzle has a YouTube video, so the <video> element is inside an iframe. You should right click > Inspect element on the YouTube video (you may have to right click a few times to show the browser's right click menu), and then try pasting the code.

@achow0
Copy link

achow0 commented Mar 25, 2021

In my case, I didn't find a <video> element, but instead only an <iframe>. Should I replace video = document.querySelector('video') with video = document.querySelector('iframe') or what?

@SheepTester
Copy link
Author

image
You will have to select the YouTube frame in the dropdown; this is automatically selected if you right click > Inspect element on the YouTube video itself rather than the outer website

@achow0
Copy link

achow0 commented Mar 26, 2021

image

Thank you, that worked. But edpuzzle is now detecting that I'm skipping ahead, even at a 2x speed(Edit: I got it to work at 2x speed, but anything like 4x speed won't work). This will cause the video to be paused very often, and the final result is that it's actually slower than watching it normally. Is there a way to bypass this problem?

@SheepTester
Copy link
Author

Hmm, this video recommends skipping to the end of the video. You can use their method, or use JS; both work:

video = document.querySelector('video')
video.currentTime = video.duration

Then you could open the video in a new tab and watch it at whatever speed you please

@gosoccerboy5
Copy link

Could they not have just defined a setter for the video named playbackRate that will block any attempts to change the playback rate? Or would that throw some error (or be worked around with something like setAttribute)?

@SheepTester
Copy link
Author

Probably; hopefully they don't

@Ricksbinder
Copy link

Does anyone have an idea if we can also modify how long it says it took to take the edpuzzle on an admin/teacher account page?

@GinjaNinja5197
Copy link

anyone got a bookmarklet for this

@SheepTester
Copy link
Author

SheepTester commented Jan 26, 2022

javascript:(() => { const speed = prompt('Speed', 2), video = document.querySelector('video'); Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'playbackRate').set.call(video, speed); Object.defineProperty(video, 'playbackRate', { writable: false }) })()

@anhdq201
Copy link

Can you help me rewind the video?

@SheepTester
Copy link
Author

Rewind? Does Edpuzzle block seeking previous parts of the video?

@GinjaNinja5197
Copy link

this dont work no more

@SheepTester
Copy link
Author

oh well. it's an arms race

@GinjaNinja5197
Copy link

have you fixed it i have a 40 minute long video to watch

@SheepTester
Copy link
Author

lazy

@kickturn
Copy link

Use the method to skip to the end, that one just worked for me on a 24 minute video.

@GinjaNinja5197
Copy link

my school blocked inspect element

@GinjaNinja5197
Copy link

you alive @SheepTester

@SheepTester
Copy link
Author

that sucks

@GinjaNinja5197
Copy link

have you figured out a fix for it because i know nothing about coding

@SheepTester
Copy link
Author

no

@GinjaNinja5197
Copy link

I found a fix using a Inspect element bookmarklet and deleting a lot of stuff around the video which unlocks the video so i just skip through refresh the page and answer the questions.

@rsangimino335
Copy link

can you make it so a can fast forward throught the video

@treeesswebsite
Copy link

Yes pls Fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment