YouTube homepage remover

Remove videos from the homepage and place an inspirational quote

  1. // ==UserScript==
  2. // @name YouTube homepage remover
  3. // @description Remove videos from the homepage and place an inspirational quote
  4. // @version 1.1
  5. // @author RavenEXP
  6. // @grant GM.xmlHttpRequest
  7. // @include *://*.youtube.com/
  8. // @include *://*.youtu.be/
  9. // @require http://code.jquery.com/jquery-3.4.1.min.js
  10. // @run-at document-end
  11. // @compatible firefox
  12. // @compatible chrome
  13. // @namespace https://gf.qytechs.cn/users/530932
  14. // ==/UserScript==
  15.  
  16. //Set the time for the script to expire
  17. var workUntil = "17:30"
  18.  
  19. //Check if the current time will "break" youtube
  20. var d = new Date();
  21. var currentTime = d.getHours() + ":" + d.getMinutes();
  22.  
  23. if(currentTime < workUntil)
  24. {
  25. //Remove homepage videos and side bar
  26. $("#end.ytd-masthead").remove();
  27. $("#page-manager").remove();
  28. $("#guide-content.ytd-app").remove();
  29. $("#guide-button.ytd-masthead").remove();
  30. //Create the paragraphs for the quote and quote author
  31. $("ytd-app").append("<div id =\"quotePlace\"\">")
  32. $("#quotePlace").append("<p id=\"quote\"></p> <p id=\"author\"></p> </div>");
  33.  
  34. //Apply css to the quote and quote author
  35. $("#quotePlace").css({"padding-top": "15%",
  36. "padding-left": "25%",
  37. "padding-right": "25%",
  38. "font-size": "240%",
  39. "color": "#f00",
  40. "-webkit-filter": "invert(50%)",
  41. "filter": "invert(50%)"});
  42. //Take the quote and quote author and put them in there paragraphs
  43. var apiArray = new Array();
  44. GM.xmlHttpRequest({
  45. method: "GET",
  46. url: "https://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=xml&lang=en",
  47. responseType: "xml",
  48. onload: function(data) {
  49. apiArray = getXMLToArray(data.responseText);
  50. console.log(apiArray.QUOTE.QUOTETEXT[0]);
  51. console.log(apiArray.QUOTE.QUOTEAUTHOR[0]);
  52. $("#quote").html('"' + apiArray.QUOTE.QUOTETEXT[0] + '"');
  53. $("#author").html('-' + apiArray.QUOTE.QUOTEAUTHOR[0]);
  54. }
  55. });
  56. }
  57.  
  58.  
  59. function getXMLToArray(xmlDoc){
  60. var thisArray = new Array();
  61. //Check XML doc
  62. if($(xmlDoc).children().length > 0){
  63. //Foreach Node found
  64. $(xmlDoc).children().each(function(){
  65. if($(xmlDoc).find(this.nodeName).children().length > 0){
  66. //If it has children recursively get the inner array
  67. var NextNode = $(xmlDoc).find(this.nodeName);
  68. thisArray[this.nodeName] = getXMLToArray(NextNode);
  69. } else {
  70. //If not then store the next value to the current array
  71. thisArray[this.nodeName] = [];
  72. $(xmlDoc).children(this.nodeName).each(function(){
  73. thisArray[this.nodeName].push($(this).text());
  74. });
  75. }
  76. });
  77. }
  78. return thisArray;
  79. }
  80.  
  81.  
  82.  
  83.  
  84.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址