Greasy Fork

Greasy Fork is available in English.

YouTube homepage remover

Remove videos from the homepage and place an inspirational quote

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        YouTube homepage remover
// @description Remove videos from the homepage and place an inspirational quote
// @version     1.1
// @author      RavenEXP
// @grant       GM.xmlHttpRequest
// @include     *://*.youtube.com/
// @include     *://*.youtu.be/
// @require   	http://code.jquery.com/jquery-3.4.1.min.js
// @run-at      document-end
// @compatible  firefox
// @compatible  chrome
// @namespace http://greasyfork.icu/users/530932
// ==/UserScript==

//Set the time for the script to expire
var workUntil = "17:30"

//Check if the current time will "break" youtube
var d = new Date(); 
var currentTime = d.getHours() + ":" + d.getMinutes();

if(currentTime < workUntil)
{
  //Remove homepage videos and side bar
 	$("#end.ytd-masthead").remove();
	$("#page-manager").remove();
	$("#guide-content.ytd-app").remove();
  $("#guide-button.ytd-masthead").remove();
  
  //Create the paragraphs for the quote and quote author
  $("ytd-app").append("<div id =\"quotePlace\"\">")
  $("#quotePlace").append("<p id=\"quote\"></p> <p id=\"author\"></p> </div>");

  //Apply css to the quote and quote author
	$("#quotePlace").css({"padding-top": "15%",
                        "padding-left": "25%",
                        "padding-right": "25%",
                        "font-size": "240%",
                        "color": "#f00",
                        "-webkit-filter": "invert(50%)",
                        "filter": "invert(50%)"});
  
  //Take the quote and quote author and put them in there paragraphs
  var apiArray = new Array();  
  GM.xmlHttpRequest({
      method: "GET",
      url: "https://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=xml&lang=en",
      responseType:   "xml",
      onload: function(data) {
        apiArray = getXMLToArray(data.responseText);
        console.log(apiArray.QUOTE.QUOTETEXT[0]);
        console.log(apiArray.QUOTE.QUOTEAUTHOR[0]);
        $("#quote").html('"' + apiArray.QUOTE.QUOTETEXT[0] + '"');
        $("#author").html('-' + apiArray.QUOTE.QUOTEAUTHOR[0]); 
      }
    });
}


function getXMLToArray(xmlDoc){
  var thisArray = new Array();
  //Check XML doc
  if($(xmlDoc).children().length > 0){
    //Foreach Node found
    $(xmlDoc).children().each(function(){
      if($(xmlDoc).find(this.nodeName).children().length > 0){
        //If it has children recursively get the inner array
        var NextNode = $(xmlDoc).find(this.nodeName);
        thisArray[this.nodeName] = getXMLToArray(NextNode);
      } else {
        //If not then store the next value to the current array
        thisArray[this.nodeName] = [];
        $(xmlDoc).children(this.nodeName).each(function(){
          thisArray[this.nodeName].push($(this).text());
        });
      }
    });
  }
  return thisArray;
}