Created
January 4, 2015 02:40
-
-
Save Pluckerpluck/155d70f830070e39d65b to your computer and use it in GitHub Desktop.
Adds show time to shows in the queue from a list
This file contains 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
// ==UserScript== | |
// @name Simulcast Queue Information | |
// @namespace com.pluckerpluck.crunchyroll | |
// @description Adds show time to shows in the queue from a list | |
// @version 1.0 | |
// @grant none | |
// @require https://code.jquery.com/jquery-2.1.3.min.js | |
// @include http://www.crunchyroll.com/home/queue | |
// ==/UserScript== | |
$(".queue-item").each(function (index){ | |
var href = $(this).find("a.episode").attr("href"); | |
var name = href.match(/\/([a-z-]+)\//)[1]; | |
var $show = $(this); | |
$.ajax({ | |
type: "GET", | |
url: "http://www.crunchyroll.com/" + name + ".rss", | |
dataType: "xml", | |
success: function(xml) { | |
var next = $(xml).find('pubDate').first().text(); | |
var date = next.split(" "); | |
var day = date[0]; | |
var timeSegments = date[4].split(":"); | |
var hours = timeSegments[0]; | |
var offset = new Date().getTimezoneOffset(); | |
var hourOffset = Math.floor(offset/60); | |
var minuteOffset = offset % 60; | |
hours = hours - hourOffset; | |
var minutes = Math.floor(((timeSegments[1] - minuteOffset) % 60) / 30) * 30; | |
minutes = ("0" + minutes).slice(-2); | |
var timeZone = date[5]; | |
var html = "<span style=\"position:absolute; top:7px; right:0; color:gray; font-size:11px;\">"+ day + " " + hours + ":" + minutes + " UTC+" + -offset/60 + "</span>"; | |
$show.find(".series-info").prepend(html); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment