niconico layout changer for GINZA

Expand video-infomation. @nicovideo(GINZA)

  1. // ==UserScript==
  2. // @id niconico_layout_changer_for_GINZA
  3. // @name niconico layout changer for GINZA
  4. // @version 1.7
  5. // @namespace https://gf.qytechs.cn/ja/scripts/2981
  6. // @homepageURL https://gf.qytechs.cn/ja/scripts/2981
  7. // @license https://creativecommons.org/licenses/by-nc-sa/3.0/
  8. // @author noi
  9. // @description Expand video-infomation. @nicovideo(GINZA)
  10. // @include http://www.nicovideo.jp/watch/*
  11. // @run-at document-start
  12. // @grant GM_log
  13. // ==/UserScript==
  14.  
  15. /**********************************************************
  16. 概要
  17. ニコニコ動画(GINZA)の「動画情報」を見やすくするためのレイアウトに変更します。
  18.  
  19. ※液晶解像度の幅が1800以上のみ動作します。
  20. ※ニコニコが「動画情報を開く」状態をcookieに保存するようになったため、低解像度の対応を外しました。
  21.  
  22.  
  23. ・動画情報と動画プレイヤーを左右に並べて表示
  24.  
  25.  
  26. ***********************************************************
  27. 更新履歴
  28.  
  29. 05/19/2016 - v1.7 fix:cssの不具合修正
  30. 05/19/2016 - v1.6 fix:kusa5.mod対応&修正
  31. 05/16/2016 - v1.5 add:要望のあったkusa5と併用できるように動画位置指定追加
  32. 11/13/2014 - v1.4 fix:ニコニコチャンネルの表示バグ&プレイヤー大画面モードのバグなど
  33. 11/13/2014 - v1.3 fix:ニコニコの仕様変更対応&大規模な作り替え
  34. 08/08/2014 - v1.2 fix:css
  35. 07/15/2014 - v1.1 fix:表示調整
  36. 07/03/2014 - v1.0 release
  37. **********************************************************/
  38.  
  39.  
  40. (function() {
  41.  
  42. const mid1920 = 500 + 70 + 30; //最小値定数(中画面プレイヤー500+情報70 + 隙間30)
  43. const nor1920 = 600 + 70 + 30; //最小値定数(大画面プレイヤー500+情報70 + 隙間30)
  44.  
  45. var mode = ""; //現在のプレイヤーサイズ
  46. var hInfo = 0; //詳細情報の高さ
  47. var height1920 = 0; //動画プレイヤー枠の高さ
  48. var move1920=0; //動画情報の移動量
  49.  
  50. var objBody = "";
  51. var objInfo = ""; //動画情報
  52. var objFrame = ""; //動画プレイヤー枠
  53.  
  54.  
  55. document.addEventListener("DOMContentLoaded", function(evt){
  56. var node = evt.target;
  57. setCSS();
  58. main(node);
  59. startObserver();
  60. }, false);
  61.  
  62.  
  63.  
  64. //要素の変更監視
  65. function startObserver(){
  66. var observer = new MutationObserver(function(mutations){
  67. mutations.forEach(function(mutation) {
  68. switch (mutation.type) {
  69.  
  70. case 'attributes' : // 属性が変更された
  71. //mutation.target; // 属性を持つ要素
  72. //mutation.attributeName; // 属性の名前
  73. //mutation.attributeNamespace; // 属性の名前空間
  74. //mutation.oldValue; // 変更前の属性値
  75.  
  76. //最大化・縮小化
  77. if(objBody.clientWidth < 1800 && objFrame.getAttribute("style") != "" && !document.getElementById('kusa5')){
  78. objFrame.setAttribute("style","");
  79. return;
  80. }else if(objFrame.getAttribute("style") == ""){
  81. check();
  82. return;
  83. }
  84.  
  85.  
  86. if(!mutation.target.id.match(/^(videoThumbnailImage|playerAlignmentArea)$/i)) return;
  87.  
  88. var strClass = mutation.target.className;
  89. //動画サイズ(size_normal(フルスクリーンもこれ)、size_medium、size_small)
  90. if(mutation.target.id.match(/^playerAlignmentArea$/i)){
  91. if(strClass.match(/^size_/)){
  92. var tmp = strClass.replace(/^size_/,"");
  93. if(mode == tmp) return;
  94.  
  95. mode = tmp
  96. check(mode);
  97. }
  98. return;
  99. }
  100.  
  101.  
  102. var thumbTitle = mutation.target.getAttribute("alt");
  103.  
  104. if(mutation.oldValue != thumbTitle){
  105. check();
  106. }
  107.  
  108. return;
  109.  
  110. }
  111. });
  112. });
  113.  
  114. var target = document.body;
  115. var config = { childList: true ,subtree: true ,attributes:true};
  116. observer.observe(target, config);
  117. }
  118.  
  119.  
  120. //main========================================================================================
  121. function main(){
  122. try{
  123.  
  124. if(!objBody){
  125. objBody = document.getElementsByTagName("body")[0];
  126. objInfo = document.getElementById("videoInfo"); //動画情報
  127. objFrame = document.getElementById("playerContainerWrapper"); //動画プレイヤー枠
  128. }
  129.  
  130. hInfo = objInfo.clientHeight; //詳細情報の高さ
  131. var hDif = hInfo - mid1920; //詳細情報と最小値定数の差分(詳細情報 - 最小値定数)
  132. height1920 = mid1920 + hDif + 30; //CSS1920に使う高さ(最小値定数 + 差分 + 隙間30)
  133. if(height1920 < mid1920) height1920 = mid1920;
  134.  
  135. if(hDif < 0) hDif = 0;
  136. move1920 = - 830 - hDif; //固定移動量-830 - 差分
  137.  
  138. setData(move1920,height1920);
  139.  
  140. }catch(e){
  141. GM_log("nicoLC:"+e);
  142. }
  143.  
  144. }//mainここまで=================================================================
  145.  
  146.  
  147. //CSS-----------------------------------
  148. function setCSS(){
  149.  
  150. /*CSS*/
  151. var css1920 = '@media screen and (min-width: 1800px) {'
  152. + '#videoDetailInformation,' /*スクリプトで上に追加される動画情報*/
  153. + '#videoComment > H4,' /*「動画説明」というタイトル*/
  154. + '.toggleDetailExpand,' /*動画詳細情報を開く*/
  155. + '.shortVideoInfo{' /*動画情報の短縮版*/
  156. + 'display:none!important;'
  157. + '}'
  158. /*下に最初から読み込まれる動画情報(動画情報を上に表示している状態では非表示にされるため)*/
  159. + '.videoMainInfoContainer{display:block!important;}'
  160. /*動画情報の背景*/
  161. + '#videoInfo{position:absolute;left:20px;z-index:999;width:calc(100% - 1120px);min-height:580px;padding:5px 0 0 20px;background:rgba(255,255,255,0.5); }'
  162. + 'body.size_normal #videoInfo{ width:calc(100% - 1350px);}'
  163. /*動画情報のタイトル部分などの調整*/
  164. + '#videoInfoHead,.videoInformation,#videoComment{ width:100%!important;}'
  165. /*動画プレイヤーの全体枠(検索などの最小化の時)*/
  166. + 'body.size_small #playerContainerWrapper{ min-height:150px!important;}'
  167. /*動画プレイヤー(普通サイズ)*/
  168. + 'body.size_medium #playerContainerSlideArea{position:absolute;top:100px;right:50px;}'
  169. /*動画プレイヤー(拡大表示)*/
  170. + 'body.size_normal #playerContainerSlideArea{position:absolute;top:100px;right:50px;}'
  171. /*kusa5の動画プレイヤー*/
  172. + 'body.size_medium #kusa5,body.size_normal #kusa5{position:absolute!important;top:100px!important;left:calc(100% - 1060px)!important; max-width:calc(100% - (100% - 1020px)); max-height: calc(100% - 150px);}'
  173. + '#playerContainerWrapper{padding:10px 0 10px 0!important;}'
  174. /*共有のポップアップ*/
  175. + '.expandContainer{position:absolute;z-index:999999;}'
  176. /*ユーザープロファイル*/
  177. + '.userProfile{position:absolute!important;top:-10px;left:calc(100% + 700px);max-width:300px!important;background:rgba(255,255,255,0.5);}'
  178. /*ユーザープロファイルの子情報*/
  179. + '.userProfile *{ max-width:200px!important; }'
  180. /*チャンネルプロファイル*/
  181. + '.ch_prof{width:350px;position:absolute!important;top:-10px;left:calc(100% + 700px);background:rgba(255,255,255,0.5);}'
  182. + '.channelFavoriteLink{float:right!important;}'
  183. /*親動画情報*/
  184. + '.parentVideoInfo{position:absolute!important;top:-10px;left:calc(100% + 20px);display:block!important;background:rgba(255,255,255,0.5);}'
  185. /*動画詳細情報を開く*/
  186. + '#bottomVideoDetailInformation{position:absolute;top:20px;right:20px;}'
  187. /*「動画詳細情報を開く」のポップアップメニュー*/
  188. + '.supplementary{position:absolute;top:20px;right:0px;z-index:99;width:300px;background:rgba(255,255,255,0.8);}'
  189.  
  190. /*ニコニコ市場*/
  191. /*市場の枠*/
  192. + '.outer{margin-left:5%!important; width:85%!important;}'
  193. + '.main{width:75%!important;}'
  194. + '#nicoIchiba,#ichibaMain{width:100%!important;}'
  195. /*改行*/
  196. + '#ichibaMain .rowJustify{display:none!important;}'
  197. /*市場アイテム*/
  198. + '.ichiba_mainitem{height:350px;}'
  199.  
  200. +'}';//ここまで
  201.  
  202.  
  203.  
  204. addStyle(css1920);
  205.  
  206. }
  207.  
  208. //===========================================================================
  209.  
  210.  
  211. //CSSを追加------------------------------------------------
  212. function addStyle(css) {
  213. var head = document.getElementsByTagName('head')[0];
  214. if (!head) { return };
  215.  
  216. var style = document.createElement('style');
  217. style.type = 'text/css';
  218. style.innerHTML = css;
  219. head.appendChild(style);
  220. }
  221.  
  222.  
  223. //動画情報のリサイズに、枠の高さと詳細情報の移動量を変更する
  224. function check(flg){
  225. if(flg == "small" || document.getElementById('kusa5'))return;
  226. var resize = 0;
  227. var hInfoNow = objInfo.clientHeight;
  228.  
  229. if(hInfo != hInfoNow){
  230. resize = hInfoNow - hInfo;
  231. hInfo = hInfoNow;
  232. }
  233.  
  234.  
  235. if(resize != 0 || flg){
  236. var sizePlayer = objFrame.getAttribute("nicoLC_height");
  237. var sizeMove = objInfo.getAttribute("nicoLC_move");
  238.  
  239. sizePlayer = parseInt(sizePlayer) + resize;
  240. sizeMove = parseInt(sizeMove) - resize;
  241.  
  242. if(flg == "normal" && sizePlayer < nor1920){
  243. sizeMove = sizeMove - (nor1920 - sizePlayer);
  244. sizePlayer = nor1920;
  245. }else if(flg == "medium"){
  246.  
  247. if(sizePlayer > hInfo && sizePlayer > mid1920 - 100) main();
  248. return;
  249. }
  250.  
  251. setData(sizeMove,sizePlayer);
  252. }
  253.  
  254. }
  255.  
  256. //リサイズに対応したデータをセット
  257. function setData(move,height){
  258. objInfo.setAttribute("nicoLC_move",move);
  259. objInfo.setAttribute("style","top:" + move + "px;");
  260. objFrame.setAttribute("nicoLC_height",height);
  261. objFrame.setAttribute("style","min-height:" + height + "px;");
  262. }
  263.  
  264. })();

QingJ © 2025

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