With Dattebayo dropping Naruto Shippuden because CrunchyRoll will legaly release just hours after TV Tokyo airs, I decided it was time to write some magic to download the videos from Crunchroll. You see, I have a HTPC in my living room and I don’t really fancy watching Naruto in a browser when the time comes.
Disclaimer: this will NOT allow you to download paid shows without paying. Personal use only, don’t be an **** and distribute the video.
This will only work in FireFox – also, it will only work on the H264 videos. Put the following code in a file and install it into GreaseMonkey:
crunchroll_video_download.js
// ==UserScript== // @name Provide download link on Crunchroll videos // @namespace http://www.crunchyroll.com/ // @description This script extracts the file name from the player code to allow the user to download it. // @include http://www.crunchyroll.com/media-*/*.html?h264=1 // ==/UserScript== // Get the div holding the player object var div = document.getElementById('showmedia_left_col_new'); // Grab the script in that div which constructs the player var script = div.getElementsByTagName('script')[0]; // Extract the configuration array from the script content var config_str = /"config":"([^"]+)"/.exec(script.innerHTML); // Decode the URI encoding which is used on the config parameter, we now have some XML structure var html = decodeURI(config_str[1]); // Grab the file tag from the XML content var filename = unescape(/([^<]+)/.exec(html)[1]); // Find the message box on this page var msgbox = document.getElementById('message_box'); // Remove the style which hides it msgbox.setAttribute('style',''); // Get all divs inside the message box var divs = msgbox.getElementsByTagName('div'); // Set this to the div which should hold the message var msgdiv = null; // Loop through all found children to find the right one, with a class name 'message-list' for(i = 0; i < divs.length; i++) { if(divs[i].className == 'message-list') { msgdiv = divs[i]; break; } }