Youtube Up Next Time Since Upload

In the up next queue on Youtube, include the time since upload as part of the displayed metadata

Version vom 14.02.2018. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Youtube Up Next Time Since Upload
// @namespace    https://github.com/deelawn/user-scripts
// @version      0.1
// @description  In the up next queue on Youtube, include the time since upload as part of the displayed metadata
// @author       deelawn
// @include      /^http(s?)://((www\.)?)youtube\.com/watch(.*)$/
// @grant        none
// @require      http://code.jquery.com/jquery-latest.js
// ==/UserScript==

// Check every second for upcoming videos with no uploaded time metadata displayed
var myTimer = setInterval(
  function () {
    'use strict';

    $("ytd-watch-next-secondary-results-renderer.ytd-watch > div[id='items']").children().each(function() {
      var nextObj;

      // The video up next is structured a bit differently, so check for that
      if($(" > div[id='head']", this).length){
        nextObj = $(" > ytd-compact-video-renderer", this);
      }else{
        nextObj = this;
      }

      if(!($(" > div[id='dismissable']", nextObj).length)){
        return;
      }

      nextObj = $(" > div[id='dismissable']", nextObj);

      // Don't add the time span if it's already there
      if($(" > a > ytd-video-meta-block > div[id='metadata'] > div[id='metadata-line'] > span[id='time-since-upload']", nextObj).length){
        return;
      }

      var rawLabel = $(" > a > h3 > span", nextObj).attr("aria-label");
      var regEx = /.*?\sby\s.*?\s(\d\s((year(s?))|(month(s?))|(day(s?))|(hour(s?))|(minute(s?))|(second(s?)))\sago)/;
      var timeSinceUpload = regEx.exec(rawLabel)[1];
      var timeSpan = "<span id=\"time-since-upload\" class=\"style-scope ytd-video-meta-block\">".concat(timeSinceUpload.concat("</span>"));

      $(" > a > ytd-video-meta-block > div[id='metadata'] > div[id='metadata-line'] > span", nextObj).after(timeSpan);
    });
  }, 1000);