Skip to content

Instantly share code, notes, and snippets.

@dotspencer
Created March 17, 2016 03:54
Show Gist options
  • Save dotspencer/b443a6289f47a64f6afd to your computer and use it in GitHub Desktop.
Save dotspencer/b443a6289f47a64f6afd to your computer and use it in GitHub Desktop.
Youtube Auto-stopper Shortcode
// ==UserScript==
// @name Youtube Stopper
// @namespace http://spencerlarry.com/
// @version 0.1
// @description Automatically stops the video before it gets to the end and shows suggested videos.
// @author You
// @match https://www.youtube.com/watch?v=z_CfRxf3kPI&enablejsapi=1
// @include http*://www.youtube.com/watch?*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
// Your code here...
var ytplayer = document.getElementById("movie_player");
window.setInterval(function(){
var ytplayer = document.getElementById("movie_player");
if(ytplayer.getDuration() - ytplayer.getCurrentTime() <= 1.0 ){
ytplayer.pauseVideo();
}
}, 500);
@thienha1
Copy link

doesnt work

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