Created
December 6, 2011 04:50
-
-
Save morrow/1436800 to your computer and use it in GitHub Desktop.
Bookmarklet to simulate the mechanics of the video site colour.com on youtube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* What it does on the page of a given youtube.com video: | |
| - Loads the HTML5 version of the current video if necessary/possible. | |
| - Mutes the video. | |
| - Stops the video after 30 seconds. | |
| - Changes the youtube logo to the colour.com one. | |
| Why? As a silly experiment to see what it's like to view muted videos limited to 30 seconds in length (the basic experience of video sharing on colour.com for now). | |
| */ | |
| if (!window.location.href.match(/html5/)) { | |
| alert("Hit this bookmarklet again once the window has re-loaded:)"); | |
| window.location.href = window.location.href + "&html5=1" | |
| } | |
| window.startTimer = function () { | |
| document.getElementById('logo').style.backgroundSize = '150%'; | |
| document.getElementById('logo').style.background = 'url(http://s.colour.com/static/4.11.0-90/app/images/landing-assets.png) 0 -738px'; | |
| if (document.getElementsByTagName("video").length == 0) { | |
| if ((new Date).getTime() - window.start > 1e4) { | |
| return alert("No video found.") | |
| } | |
| return window.setTimeout("window.startTimer()", 100) | |
| } | |
| window.video = document.getElementsByTagName("video")[0]; | |
| video.volume = 0; | |
| window.setTimeout(function () { | |
| video.pause(); | |
| video.src = video.src; | |
| document.getElementById("watch-player").innerHTML = '<div style="background:black">Broadcast has ended</div>' | |
| }, 3e4) | |
| }; | |
| window.start = (new Date).getTime(); | |
| startTimer() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:(function(){if(!window.location.href.match(/html5/)){alert("Hit this bookmarklet again once the window has re-loaded:)");window.location.href=window.location.href+"&html5=1"}window.startTimer=function(){document.getElementById('logo').style.backgroundSize='150%';document.getElementById('logo').style.background = 'url(http://s.colour.com/static/4.11.0-90/app/images/landing-assets.png) 0 -738px';if(document.getElementsByTagName("video").length==0){if((new Date).getTime()-window.start>1e4){return alert("No video found.")}return window.setTimeout("window.startTimer()",100)}window.video=document.getElementsByTagName("video")[0];video.volume=0;window.setTimeout(function(){video.pause();video.src=video.src;document.getElementById("watch-player").innerHTML='<div style="background:black">Broadcast has ended</div>'},3e4)};window.start=(new Date).getTime();startTimer()})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment