Crunchyroll Queue Fixer

fixes for crunchyroll queue page. put shows with new episodes at top; always show "no image" icon on shows with no new episodes.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name          Crunchyroll Queue Fixer
// @namespace     http://myanimelist.net/profile/mysticflute
// @description   fixes for crunchyroll queue page. put shows with new episodes at top; always show "no image" icon on shows with no new episodes.
// @match         https://www.crunchyroll.com/home/queue*
// @version       0.6
// @copyright     2013
// ==/UserScript==

(function() {
  // options
  var rearrange = true;
  var fixIcon = true;
  var minPercentage = 70;
  // var noImageUrl = "http://static.ak.crunchyroll.com/i/coming_soon_beta_wide.jpg";
  var noImageUrl = "http://static.ak.crunchyroll.com/i/no_image_beta_wide.jpg";

  // check querystring for "noarrange"
  if (window.location.search.indexOf("?no") > -1) {
    rearrange = false;
  }

  // actual work
  var queued = document.querySelectorAll("#main_content li.queue-item");
  var toMove = [];

  for (var i = 0, len = queued.length; i < len; i++) {
    var item = queued[i];
    var img = item.querySelector("img");
    var progress = item.querySelector(".episode-progress[style]");

    if (!progress) continue;

    var percentage = parseInt(progress.style.width, 10);

    if (fixIcon && img && img.src !== noImageUrl && percentage > minPercentage) {
      img.src = noImageUrl;
      progress.style.backgroundColor = "#ccc";
    }

    var isPlaceholder = (percentage === 0 && (img.src === noImageUrl));

    if (rearrange && !isPlaceholder && percentage < minPercentage && img.src !== noImageUrl) {
      toMove.push(item);
    }
  }

  if (rearrange) {
    toMove.reverse();
    for (var i = 0, len = toMove.length; i < len; i++) {
      var parent = toMove[i].parentNode;
      parent.insertBefore(toMove[i], parent.firstChild);
    }
  }
})();