YouTube Menu Adder

Gives YouTube menu back

目前为 2014-07-26 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube Menu Adder
  3. // @namespace http://www.diamonddownload.weebly.com
  4. // @version 0.6
  5. // @description Gives YouTube menu back
  6. // @include *.youtube.*
  7. // @copyright 2014+, RGSoftware
  8. // @run-at document-body
  9. // ==/UserScript==
  10.  
  11. var SignedIn = true;
  12.  
  13. //=========================================================================================================CUSTOM SETTINGS=========================================================================================================================
  14.  
  15. var MyChannel = "https://www.youtube.com/user/youtube";
  16. var Videos = "https://www.youtube.com/my_videos";
  17. var Subscriptions = "https://www.youtube.com/feed/subscriptions";
  18. var YtSettings = "https://www.youtube.com/account";
  19. var AllMyChannels = "https://www.youtube.com/channel_switcher";
  20. var Page = "Put your google+ link here";
  21. var Googlep = "Put your google+ link here/stream";
  22. var Managers = "Put your google+ link here/pages/settings/admin";
  23. var Settings = "Put your google+ link here/pages/settings/plus";
  24. var SignOut = "https://www.youtube.com/logout";
  25. var SwitchAccount = "https://accounts.google.com/AddSession";
  26.  
  27. //==================================================================================================================================================================================================================================================
  28.  
  29.  
  30. var element = document.getElementById('yt-masthead-account-picker');
  31. if (element == undefined && element == null){
  32. SignedIn = false;
  33. }
  34.  
  35.  
  36. //------------------------------------------>
  37. var mDropDownItem1_Channel = "My Channel";
  38. var mDropDownItem2_VideoManager = "Video Manager";
  39. var mDropDownItem3_Subscriptions = "Subscriptions";
  40. var mDropDownItem4_YouTubeSettings = "YouTube settings";
  41. var mDropDownItem5_AllMyChannels = "All my channels";
  42.  
  43. var gDropDownItem1_Page = "Page";
  44. var gDropDownItem2_GoogleP = "Google+";
  45. var gDropDownItem3_Managers = "Managers";
  46. var gDropDownItem3_Settings = "Settings";
  47.  
  48. var xDropDownItem1_SignOut = "Sign out";
  49. var xDropDownItem2_SwitchAccount = "Switch account";
  50. //------------------------------------------>
  51.  
  52.  
  53. var bClicked = false;
  54. var myMenuRef = null;
  55.  
  56. var par = document.getElementById('appbar-onebar-upload-group');
  57.  
  58. function createSelectBox(){
  59. if (SignedIn == true){
  60. var menu = document.createElement('select');
  61. menu.setAttribute('id', 'myMenu');
  62. menu.setAttribute('class', 'yt-uix-button yt-uix-sessionlink yt-uix-button-default yt-uix-button-size-default');
  63. menu.setAttribute('style', 'border-left: none; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 0px; border-top-left-radius: 0px; width: 141px; padding-left: 10px; box-shadow: 0 1px 0 rgba(0,0,0,0.05);');
  64. var ubtn = document.getElementById('upload-btn');
  65. ubtn.style.borderTopRightRadius = "0px";
  66. ubtn.style.borderBottomRightRadius = "0px";
  67. //03 July, youTube added button border radius off 2px and moved the upload button 4px more away from the right. They also made the siderbar on videos 42px higher.
  68. // float: left; height: 28px; position: relative; right:18px; border: 1px solid #c9eeff; color: white; padding: 3px; background: #1ea9ea;'
  69. par.appendChild(menu);
  70. }
  71. }
  72.  
  73. createSelectBox();
  74.  
  75. myMenuRef = document.getElementById('myMenu');
  76.  
  77. function createOptionsElements(itmVar, OptInt){
  78. if (SignedIn == true){
  79. var opt = document.createElement('option');
  80. opt.setAttribute('value', itmVar);
  81. opt.innerHTML = itmVar;
  82. opt.setAttribute('id', OptInt);
  83. myMenuRef.appendChild(opt);
  84. }
  85. }
  86.  
  87. function goToUrl(url){
  88. if (SignedIn == true){
  89. window.location.href = url;
  90. }
  91. }
  92.  
  93. function OptionChanged(){
  94. if (SignedIn == true){
  95. var selval = myMenuRef.options[myMenuRef.selectedIndex].value;
  96. switch(selval){
  97. case mDropDownItem1_Channel:
  98. goToUrl(MyChannel);
  99. break;
  100. case mDropDownItem2_VideoManager:
  101. goToUrl(Videos);
  102. break;
  103. case mDropDownItem3_Subscriptions:
  104. goToUrl(Subscriptions);
  105. break;
  106. case mDropDownItem4_YouTubeSettings:
  107. goToUrl(YtSettings);
  108. break;
  109. case mDropDownItem5_AllMyChannels:
  110. goToUrl(AllMyChannels);
  111. break;
  112. case gDropDownItem1_Page:
  113. goToUrl(Page);
  114. break;
  115. case gDropDownItem2_GoogleP:
  116. goToUrl(Googlep);
  117. break;
  118. case gDropDownItem3_Managers:
  119. goToUrl(Managers);
  120. break;
  121. case gDropDownItem3_Settings:
  122. goToUrl(Settings);
  123. break;
  124. case xDropDownItem1_SignOut:
  125. goToUrl(SignOut);
  126. break;
  127. case xDropDownItem2_SwitchAccount:
  128. goToUrl(SwitchAccount);
  129. break;
  130. }
  131. }
  132. }
  133.  
  134. createOptionsElements("", "opt_blank0");
  135. createOptionsElements("YouTube Options", "Option_Select");
  136. createOptionsElements(mDropDownItem1_Channel, "Option1");
  137. createOptionsElements(mDropDownItem2_VideoManager, "Option2");
  138. createOptionsElements(mDropDownItem3_Subscriptions, "Option3");
  139. createOptionsElements(mDropDownItem4_YouTubeSettings, "Option4");
  140. createOptionsElements(mDropDownItem5_AllMyChannels, "Option5");
  141. createOptionsElements("", "opt_blank1");
  142. createOptionsElements(gDropDownItem1_Page, "Option6");
  143. createOptionsElements(gDropDownItem2_GoogleP, "Option7");
  144. createOptionsElements(gDropDownItem3_Managers, "Option8");
  145. createOptionsElements(gDropDownItem3_Settings, "Option9");
  146. createOptionsElements("", "opt_blank2");
  147. createOptionsElements(xDropDownItem1_SignOut, "Option10");
  148. createOptionsElements(xDropDownItem2_SwitchAccount, "Option11");
  149. createOptionsElements("", "opt_blank3");
  150.  
  151. document.getElementById("opt_blank3").disabled=true;
  152. document.getElementById("opt_blank2").disabled=true;
  153. document.getElementById("opt_blank1").disabled=true;
  154. document.getElementById("opt_blank0").disabled=true;
  155. var opt = document.getElementById("Option_Select");
  156. opt.style.display='none';
  157. opt.selected=true;
  158.  
  159. myMenuRef.onchange = function(){OptionChanged();};
  160.  
  161.  
  162. //===========================DEV===================================
  163.  
  164. //background: -moz-linear-gradient(top, #1ea9ea 0%, #4096ee 100%); \
  165. //background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1ea9ea), color-stop(100%,#4096ee)); \
  166. //background: -webkit-linear-gradient(top, #1ea9ea 0%,#4096ee 100%); \
  167. //background: -o-linear-gradient(top, #1ea9ea 0%,#4096ee 100%); \
  168. //background: -ms-linear-gradient(top, #1ea9ea 0%,#4096ee 100%); \
  169. //background: linear-gradient(to bottom, #1ea9ea 0%,#4096ee 100%);
  170.  
  171. //=================================================================