YouTubeããªãã¼ãåçããGreasemonkey (&Bookmarklet)
æ¢ã«ãããããããªããã©ä½ã£ã¦ã¿ãã
ã¨ããããdocument.getElementById('movie_player')
ããããã°YouTube JavaScript Player APIã使ããã¨ãããã¨ãããã£ãã
æ©è½
- ãããªã®åçãçµãã£ããåæã«ãªãã¼ãåçããã
- å³ä¸ã®ãã¿ã³(AutoPagerizeã®ãã¯ãª)ã§ãªãã¼ãåçã®ONï¼OFFãåãæ¿ããããã
Greasemonkey
ã¹ã¯ãªããããµã¼ãã¼ã«ãããã
Youtube Repeat
ã½ã¼ã¹ã¯ä»¥ä¸ã®éãã
// ==UserScript== // @name Youtube Repeat // @description Repeat Youtube playing // @namespace http://d.hatena.ne.jp/hysa/ // @include http://www.youtube.com/* // ==/UserScript== (function() { var p = document.getElementById('movie_player').wrappedJSObject; if (p === null) return; var on = GM_getValue('repeat', true); setInterval( /** * Repeat the video. * if the video is ended, play the video again. * * @param {number} state the state of the player. */ function repeat() { if (p.getPlayerState() === State.ENDED && on) { p.playVideo(); } } , 1000); /** * Enum for the state of the player * * @enum {number} */ var State = { UNSTARTED: -1, ENDED: 0, PLAYING: 1, PAUSED: 2, BUFFERING: 3, VIDEO_CUED: 5 }; /** * Create a button. * */ (function createButton() { var button = document.createElement('div'); var style = button.style; /** * Set style on the button. */ function setStyle() { style.background = 'none repeat scroll 0 0 #0F0'; style.color = '#FFF'; style.fontSize = '12px'; style.height = '10px'; style.position = 'fixed'; style.right = '3px'; style.top = '3px'; style.width = '10px'; style.zIndex = '255'; if (!on) { style.backgroundColor = '#CCC'; } } button.addEventListener( 'click', /** * Toggle switch. * */ function() { if (on) { style.backgroundColor = '#CCC'; } else { style.backgroundColor = '#0F0'; } on = !on; GM_setValue('repeat', on); }, false ); setStyle(); document.body.appendChild(button); })(); })();
Bookmarklet
IE8ãFirefoxãGoogle Chromeã®ã¿ç¢ºèªã
javascript:(function(s){ s.src = 'http://hysa.main.jp/public/gm/YoutubeRepeat.js';document.body.appendChild(s);})(document.createElement('script'));