Przeróbka nowego YouTube

Podnosi pasek akcji na pasek przycisku subskrypcji, stale wyświetla ilość subskrypcji a do daty dodaje pełną nazwą miesiąca.

当前为 2014-11-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Przeróbka nowego YouTube
  3. // @description Podnosi pasek akcji na pasek przycisku subskrypcji, stale wyświetla ilość subskrypcji a do daty dodaje pełną nazwą miesiąca.
  4. // @version 5.04.096 beta
  5. // @author look997
  6. // @license MIT License
  7. // @resource metadata https://github.com/look997/PNYT/raw/master/pnyt.user.js
  8. // @include *youtube.com/*
  9. // @date 2014-11-08
  10. // @grant none
  11. // @namespace https://greasyfork.org/users/4353
  12. // ==/UserScript==
  13. "use strict";
  14.  
  15. document.cookie = "wide=1; domain=.youtube.com";
  16. function $(a) {return document.getElementById(a);}
  17. if ($("watch7-container")) {
  18. $("watch7-container").className = "watch-wide";
  19. }
  20.  
  21. function wymFun () {
  22. document.querySelector("#watch7-user-header").appendChild(document.querySelector("#watch8-action-buttons"));
  23. document.querySelector("#watch7-user-header").appendChild(document.querySelector("#watch8-sentiment-actions"));
  24. document.querySelector("#watch7-user-header").appendChild(document.querySelector("#watch7-views-info"));
  25. /*var docFrag = document.createDocumentFragment();
  26. docFrag.appendChild(document.querySelector("#watch8-action-buttons"));
  27. docFrag.appendChild(document.querySelector("#watch8-sentiment-actions"));
  28. docFrag.appendChild(document.querySelector("#watch7-views-info"));
  29. document.querySelector("#watch7-user-header").appendChild(docFrag);*/
  30. var addBut = document.querySelector("#watch8-secondary-actions .addto-button .yt-uix-button-content").textContent;
  31. var shareBut = document.querySelector('#watch8-secondary-actions [data-trigger-for="action-panel-share"] .yt-uix-button-content').textContent;
  32. var moreBut = document.querySelector('#action-panel-overflow-button .yt-uix-button-content').textContent;
  33. var addBut = document.querySelector("#watch8-secondary-actions .addto-button").title = addBut;
  34. var shareBut = document.querySelector('#watch8-secondary-actions [data-trigger-for="action-panel-share"]').title = shareBut;
  35. var shareBut = document.querySelector('#action-panel-overflow-button').title = moreBut;
  36. // Pełna nazwa miesiąca dodania filmu
  37. var infoDate = document.querySelector("#watch-uploader-info strong");
  38. var datfilm = infoDate.textContent;
  39. var odatmies = datfilm.substring(datfilm.length-8, datfilm.length-5);
  40. switch (odatmies){
  41. case 'sty': var datmies = "stycznia"; break;
  42. case 'lut': var datmies = "lutego"; break;
  43. case 'mar': var datmies = "marca"; break;
  44. case 'kwi': var datmies = "kwietnia"; break;
  45. case 'maj': var datmies = "maja"; break;
  46. case 'cze': var datmies = "czerwca"; break;
  47. case 'lip': var datmies = "lipca"; break;
  48. case 'sie': var datmies = "sierpnia"; break;
  49. case 'wrz': var datmies = "września"; break;
  50. case 'paź': var datmies = "października"; break;
  51. case 'lis': var datmies = "listopada"; break;
  52. case 'gru': var datmies = "grudnia"; break;
  53. default: var datmies = odatmies;
  54. }
  55. infoDate.textContent = datfilm.replace(odatmies, datmies);
  56. }
  57.  
  58. function glFun () { // GŁÓWNA FUNKCJA
  59. dodajStyl('dataDodSId',''
  60. +"#watch8-secondary-actions .yt-uix-button-content { display: none; }"
  61. //Poprawka 5.03.090
  62. +"#watch-headline-title { margin-bottom: 0px !important; }"
  63. +"#watch7-user-header { padding-top: 10px !important; }"
  64. // auto hide
  65. +"#watch7-user-header:hover #watch8-action-buttons { visibility: visible !important; }"
  66. +"#watch8-action-buttons { visibility: hidden !important; }" // Domyślnie ukryty pasek akcji
  67. // Podniesienie i dopasowanie paska akcji
  68. +"#watch8-secondary-actions { position: relative; }"
  69. //+"#watch7-views-info { top: -8px !important; bottom: auto !important; right: 0px !important; }"
  70. +"#watch7-views-info { bottom: 31px !important; width: 192px !important; }"
  71. +"#watch7-user-header { padding-bottom: 3px !important; }"
  72. +"#watch8-action-buttons { display: inline; padding-top: 0px; border-top: none; }"
  73. +"#watch8-action-buttons:after,"
  74. +"#watch8-action-buttons:before { content: none !important; }"
  75. +"#watch8-secondary-actions .yt-uix-button { padding: 0px 0px !important; }"
  76. +"#watch8-secondary-actions { left: 5px !important; }"
  77. // Stałe wyświetlanie liczby subskrybcji kanału autora filmu
  78. +".yt-subscription-button-subscriber-count-branded-horizontal, .html5-text-button, .yt-subscription-button-subscriber-count-unbranded { display: inline-block !important; }"
  79. // Skok do aktualnie odtwarzanego elementu na playliście
  80. +" .watch-wide #watch-appbar-playlist .playlist-videos-list { "
  81. +" height: 490px !important; "
  82. +" } "
  83. +" .watch-wide #watch-appbar-playlist { "
  84. +" min-height: 592px !important; "
  85. +" } "
  86. +" #watch-appbar-playlist .playlist-videos-list { "
  87. +" max-height: 490px !important; "
  88. +" } "
  89. );
  90. }
  91.  
  92.  
  93. function dodajStyl (idStyle,styles) { // Dodanie stylu
  94. if(document.getElementById(idStyle)){ document.getElementsByTagName("head")[0].removeChild(document.getElementById(idStyle)); }
  95. var css = document.createElement('style'); css.type = 'text/css'; css.id = idStyle;
  96. css.styleSheet ? css.styleSheet.cssText = styles : css.appendChild( document.createTextNode(styles) );
  97. document.getElementsByTagName("head")[0].appendChild(css);
  98. }
  99.  
  100.  
  101. function readCookie (name) {
  102. var nameEQ = name + "=";
  103. var ca = document.cookie.split(';');
  104. for(var i=0;i < ca.length;i++) {
  105. var c = ca[i];
  106. while (c.charAt(0)==' ') c = c.substring(1,c.length);
  107. if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  108. }
  109. return null;
  110. }
  111.  
  112. function setTOFun() {
  113. setTimeout( function () {
  114. console.log("setTOFun");
  115. if (document.querySelector("#progress") == undefined) {
  116. wymFun();
  117. }
  118. else {
  119. setTOFun();
  120. }
  121. }, 100);
  122. }
  123.  
  124. function miedzyFun () {
  125. glFun();
  126. wymFun();
  127. //window.alert("muędzy");
  128. console.log("miedzyFun");
  129. /*(function(history){
  130. var pushState = history.pushState;
  131. history.pushState = function(state) {
  132. if (typeof history.onpushstate == "function") {
  133. history.onpushstate({state: state});
  134. }
  135. // ... whatever else you want to do
  136. // maybe call onhashchange e.handler
  137. return pushState.apply(history, arguments);
  138. }
  139. })(window.history);
  140. history.onpopstate = history.onpushstate = function(e) { console.log("pushstate"); glFun(); }
  141. */
  142. window.addEventListener("popstate", function(e) {
  143. console.log("popstate"); //popstate
  144. setTOFun();
  145. });
  146. }
  147.  
  148. document.addEventListener("DOMContentLoaded", miedzyFun);