MOD_Seiga

ニコニコ静画のUIをいじる

目前為 2014-07-29 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name MOD_Seiga
  3. // @namespace https://github.com/segabito/
  4. // @description ニコニコ静画のUIをいじる
  5. // @include http://seiga.nicovideo.jp/seiga/*
  6. // @include http://seiga.nicovideo.jp/tag/*
  7. // @include http://seiga.nicovideo.jp/illust/*
  8. // @include http://lohas.nicoseiga.jp/o/*
  9. // @version 0.3.3
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. // ver 0.2.20
  14. // ver 0.2.21
  15. // - 新バージョンに対応
  16.  
  17. // ver 0.2.13
  18. // - クリップの向きが変わったので、クリップメニューの位置を設定できるようにした
  19.  
  20. // ver 0.2.12
  21. // - コメント一覧で一番下のコメントが見きれる問題二を勝手に直す
  22. // - タグ検索時にキーワード検索フォームに自動でタグのテキストを入れる
  23.  
  24. // ver 0.2.11
  25. // - コメント中の動画・静画IDやURLへのリンクに対応
  26. // - 春画でも説明文のURL自動リンクに対応
  27. // - 切れないサムネをAutopagerizeに対応
  28.  
  29. // ver 0.2.10
  30. // - ヘッダ固定の時の自動スクロール修正
  31. // - タグ検索時にカウンターが常時表示されるように変更
  32. // - ページ下側の投稿者アイコンを隠す設定 (右上だけあればいい人用)
  33.  
  34. // ver 0.2.9
  35. // - 動画タイトルの位置に自動スクロールする対応
  36. // - おもにwindows等、縦ホイールしかない環境で横スクロールしやすくする。Firefoxでうまくいかない
  37. // - ウィンドウ幅が狭いときはページ一番上に戻るボタンを出さなくする設定
  38.  
  39. // ver 0.2.8
  40. // - クリップボタンの位置を上にしてみる
  41. // - 右上の投稿者アイコンを大きくしてみる
  42.  
  43. // ver 0.2.7
  44. // - 全画面表示時に画像クリックでズームが切り替わる対応
  45.  
  46. // ver 0.2.6
  47. // - サムネイルがカットされなくする対応をタグ検索とイラストトップにも適用
  48.  
  49. // ver 0.2.5
  50. // - サムネイルがカットされなくする対応。 設定で無効にも出来ます
  51.  
  52. // ver 0.2.4
  53. // - 右カラム広告のせいで無駄に横スクロールが発生しているのを勝手に直す
  54.  
  55. // ver 0.2.3
  56. // - 市場を近づけた
  57.  
  58. // ver 0.2.2
  59. // - ホバーしなくてもタイトルと説明文が出るように
  60.  
  61. // ver 0.2.1
  62. // - タグを説明文の下・説明文の右に置けるように
  63.  
  64. // ver 0.2.0
  65. // - 動かなくなっていたのでとりあえずまた動くようにした
  66.  
  67. // ver 0.1.0
  68. // - 設定パネルを追加
  69. // - 投稿者を右上に出せるようにした
  70.  
  71. // ver 0.0.2
  72. // - ホバーしなくてもタイトルと説明文が出るように
  73. // - 見えないところでタグが増殖していたのを修正
  74.  
  75. // ver 0.0.1 最初のバージョン
  76.  
  77. (function() {
  78. var monkey = (function(){
  79. 'use strict';
  80. var $ = window.jQuery;
  81.  
  82. var A4_WIDTH = 210, A4_HEIGHT = 297;
  83.  
  84.  
  85. window.MOD_Seiga = {
  86. initialize: function() {
  87. this.initializeUserConfig();
  88. var path = location.pathname;
  89. if (path.indexOf('/seiga/') === 0) {
  90. this.initializeSeigaView();
  91. } else
  92. if (path.indexOf('/illust/') === 0 && path.indexOf('ranking') < 0) {
  93. this.initializeIllustTop();
  94. } else
  95. if (path.indexOf('/tag/') === 0) {
  96. this.initializeTagSearch();
  97. } else
  98. if (path.indexOf('/o/') === 0) {
  99. this.initializeFullView();
  100. }
  101.  
  102. },
  103. initializeSeigaView: function() {
  104. if ($('#content').length > 0) {
  105. this.initializeBaseLayout();
  106.  
  107. this.initializeScrollTop();
  108. this.initializeDescription();
  109. this.initializeCommentLink();
  110. this.initializeThumbnail();
  111. this.initializePageTopButton();
  112. this.initializeKnockout();
  113. this.initializeFullScreenRequest();
  114.  
  115. this.initializeOther();
  116. this.initializeSettingPanel();
  117.  
  118. $('body').addClass('MOD_Seiga_View');
  119. this.initializeCss();
  120. } else {
  121. // 春画っぽい。説明文の自動リンクだけやる
  122. this.initializeDescription();
  123. }
  124.  
  125. },
  126. initializeIllustTop: function() {
  127. this.initializeThumbnail();
  128. this.initializeSettingPanel();
  129.  
  130. this.initializePageTopButton();
  131. $('body').addClass('MOD_Seiga_Top');
  132. this.initializeCss();
  133. },
  134. initializeTagSearch: function() {
  135. this.initializeThumbnail();
  136. this.initializeSettingPanel();
  137.  
  138. this.initializePageTopButton();
  139. setTimeout(function() {
  140. var $search = $('#bar_search');
  141. if (
  142. $search.val() === 'イラストを検索' ||
  143. $search.val() === '春画を検索') {
  144. $search.val($('#ko_tagwatch_min').attr('data-query')).addClass('edited').css({color: '#000'});
  145. }
  146. }, 1000);
  147. $('body').addClass('MOD_Seiga_TagSearch');
  148. this.initializeCss();
  149. },
  150. initializeFullView: function() {
  151. $('body').addClass('MOD_Seiga_FullView');
  152. this.initializeFullscreenImage();
  153. this.initializeCss();
  154. },
  155. addStyle: function(styles, id) {
  156. var elm = document.createElement('style');
  157. elm.type = 'text/css';
  158. if (id) { elm.id = id; }
  159.  
  160. var text = styles.toString();
  161. text = document.createTextNode(text);
  162. elm.appendChild(text);
  163. var head = document.getElementsByTagName('head');
  164. head = head[0];
  165. head.appendChild(elm);
  166. return elm;
  167. },
  168. fullScreen: {
  169. now: function() {
  170. if (document.fullScreenElement || document.mozFullScreen || document.webkitIsFullScreen) {
  171. return true;
  172. }
  173. return false;
  174. },
  175. request: function(target) {
  176. var elm = typeof target === 'string' ? document.getElementById(target) : target;
  177. if (!elm) { return; }
  178. if (elm.requestFullScreen) {
  179. elm.requestFullScreen();
  180. } else if (elm.webkitRequestFullScreen) {
  181. elm.webkitRequestFullScreen();
  182. } else if (elm.mozRequestFullScreen) {
  183. elm.mozRequestFullScreen();
  184. }
  185. },
  186. cancel: function() {
  187. if (document.cancelFullScreen) {
  188. document.cancelFullScreen();
  189. } else if (document.webkitCancelFullScreen) {
  190. document.webkitCancelFullScreen();
  191. } else if (document.mozCancelFullScreen) {
  192. document.mozCancelFullScreen();
  193. }
  194. }
  195. },
  196. initializeCss: function() {
  197. var __common_css__ = (function() {/*
  198. .MOD_SeigaSettingMenu a {
  199. font-weight: bolder; color: darkblue !important;
  200. }
  201. #MOD_SeigaSettingPanel {
  202. position: fixed;
  203. bottom: 2000px; right: 8px;
  204. z-index: -1;
  205. width: 500px;
  206. background: #f0f0f0; border: 1px solid black;
  207. padding: 8px;
  208. transition: bottom 0.4s ease-out;
  209. text-align: left;
  210. }
  211. #MOD_SeigaSettingPanel.open {
  212. display: block;
  213. bottom: 8px;
  214. box-shadow: 0 0 8px black;
  215. z-index: 10000;
  216. }
  217. #MOD_SeigaSettingPanel .close {
  218. position: absolute;
  219. cursor: pointer;
  220. right: 8px; top: 8px;
  221. }
  222. #MOD_SeigaSettingPanel .panelInner {
  223. background: #fff;
  224. border: 1px inset;
  225. padding: 8px;
  226. min-height: 300px;
  227. overflow-y: scroll;
  228. max-height: 500px;
  229. }
  230. #MOD_SeigaSettingPanel .panelInner .item {
  231. border-bottom: 1px dotted #888;
  232. margin-bottom: 8px;
  233. padding-bottom: 8px;
  234. }
  235. #MOD_SeigaSettingPanel .panelInner .item:hover {
  236. background: #eef;
  237. }
  238. #MOD_SeigaSettingPanel .windowTitle {
  239. font-size: 150%;
  240. }
  241. #MOD_SeigaSettingPanel .itemTitle {
  242. }
  243. #MOD_SeigaSettingPanel label {
  244. margin-right: 12px;
  245. }
  246. #MOD_SeigaSettingPanel small {
  247. color: #666;
  248. }
  249. #MOD_SeigaSettingPanel .expert {
  250. margin: 32px 0 16px;
  251. font-size: 150%;
  252. background: #ccc;
  253. }
  254.  
  255. .comment_info .mod_link, .description .otherSite {
  256. text-decoration: underline;
  257. font-weight: bolder;
  258. }
  259.  
  260. {* 画面が狭いときに操作不能になる部分などを直す *}
  261. @media screen and (max-width: 1023px) {
  262. .mod_hidePageTopButton.MOD_Seiga .comment_all .comment_all_inner .illust_main .illust_side .illust_comment .comment_list {
  263. position: fixed;
  264. right: 25px;
  265. top: 105px; bottom: 105px; overflow-y: auto;
  266. }
  267. .mod_hidePageTopButton.MOD_Seiga .comment_all .comment_all_inner .illust_main .illust_side .illust_comment .comment_list .text {
  268. margin: 0 16px 0 0;
  269. }
  270. .mod_hidePageTopButton.MOD_Seiga .comment_all .comment_all_inner .illust_main .illust_side .illust_comment .res .inner {
  271. position: fixed;
  272. bottom: 0; right: 5px;
  273. }
  274. .mod_hidePageTopButton.MOD_Seiga .comment_all .comment_all_header .control{
  275. position: fixed; top: 35px; right: 25px; {* 横幅が狭いと閉じるを押せない問題の対応 *}
  276. }
  277. }
  278. @media screen and (max-width: 1183px) {
  279. .mod_hidePageTopButton #pagetop { display: none !important; }
  280. }
  281.  
  282.  
  283. @media print {
  284. body {
  285. background: #000 !important; {* 背景を黒にしたい場合は「背景画像を印刷」にチェック *}
  286. margin: 0;
  287. padding: 0;
  288. overflow: hidden;
  289. width: 210mm;
  290. height: calc(297mm - 19mm); {* 19mmは印刷マージン *}
  291. }
  292. body.landscape {
  293. width: 297mm;
  294. height: calc(210mm - 19mm);
  295. }
  296. .toggleFullScreen, .control {
  297. display: none !important;
  298. opacity: 0 !important;
  299. }
  300.  
  301. .MOD_Seiga_FullView .illust_view_big img {
  302. top: 0 !important;
  303. left: 0 !important;
  304. transform: inherit !important;
  305. -webkit-transform: inherit !important;
  306. }
  307.  
  308. .MOD_Seiga_FullView:not(.landscape) .illust_view_big img {
  309. width: auto;
  310. height: auto;
  311. }
  312. .MOD_Seiga_FullView:not(.landscape).fitV .illust_view_big img {
  313. {*width: auto;
  314. height: calc(297mm - 19mm); *}
  315. }
  316. .MOD_Seiga_FullView.landscape .illust_view_big img {
  317. {*width: 297mm;
  318. height: auto; *}
  319. }
  320. .MOD_Seiga_FullView.landscape.fitV .illust_view_big img {
  321. {*width: auto;
  322. height: calc(210mm - 19mm); *}
  323. margin-top: 0;
  324. }
  325. }
  326.  
  327. {* 用紙を縦にするか横にするかで変えたかった *}
  328. {*
  329. @media print and (max-width: 210mm) {
  330. .MOD_Seiga_FullView .illust_view_big,
  331. body {
  332. width: 210mm;
  333. height: 297mm;
  334. }
  335.  
  336. .MOD_Seiga_FullView .illust_view_big img {
  337. width: 210mm !important;
  338. height: auto !important;
  339. margin-top: calc(297mm / 2 - 50%);
  340. }
  341. }
  342. *}
  343.  
  344. {*
  345. @media print and (min-width: 211mm) {
  346. .MOD_Seiga_FullView .illust_view_big,
  347. body {
  348. width: 297mm;
  349. height: 210mm;
  350. }
  351.  
  352. .MOD_Seiga_FullView .illust_view_big img {
  353. width: auto !important;
  354. height: 210mm !important;
  355. margin-left: calc(210mm / 2 - 50%);
  356. }
  357. }
  358. *}
  359.  
  360.  
  361. */}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1].replace(/\{\*/g, '/*').replace(/\*\}/g, '*/');
  362.  
  363. var __css__ = (function() {/*
  364.  
  365.  
  366. {* マイページや投稿へのリンクがあっても、すぐ上にniconico共通のヘッダーがあるのでいらないと思う。ということで省スペース優先で消す。*}
  367. #header { background: #fff; }
  368. #header .sg_global_bar {
  369. display: none;
  370. }
  371. #header_cnt { width: 1004px; }
  372.  
  373. {* サムネのホバー調整 *}
  374. .list_item_cutout.middle {
  375. height: 154px;
  376. text-align: center;
  377. }
  378. .list_item_cutout.middle a {
  379. height: 100%;
  380. overflow: visible;
  381. }
  382. .list_item_cutout.middle a .illust_info, .list_item_cutout.middle a .illust_info:hover {
  383. bottom: 0;
  384. }
  385.  
  386. {* サムネのカットなくすやつ。 *}
  387. .list_item_cutout.mod_no_trim .thum img {
  388. display: none;
  389. }
  390.  
  391.  
  392. .list_item_cutout.mod_no_trim .thum {
  393. display: block;
  394. width: 100%;
  395. height: calc(100% - 40px);
  396. background-repeat: no-repeat;
  397. background-position: center center;
  398. background-size: contain;
  399. -moz-background-size: contain;
  400. -webkit-background-size: contain;
  401. -o-background-size: contain;
  402. -ms-background-size: contain;
  403. }
  404.  
  405. .list_item.mod_no_trim .thum img {
  406. display: none;
  407. }
  408.  
  409. .list_item.mod_no_trim .thum {
  410. display: block;
  411. width: 100%;
  412. height: 0;
  413. background-repeat: no-repeat;
  414. background-position: center center;
  415. background-size: contain;
  416. -moz-background-size: contain;
  417. -webkit-background-size: contain;
  418. -o-background-size: contain;
  419. -ms-background-size: contain;
  420. }
  421. .MOD_Seiga_View .list_item.mod_no_trim .thum {
  422. }
  423. .list_item.mod_no_trim .thum:hover, .list_item_cutout.mod_no_trim .thum:hover {
  424. background-size: cover;
  425. }
  426.  
  427. .MOD_Seiga_Top .list_item_cutout.mod_no_trim .thum {
  428. height: calc(100% - 50px);
  429. }
  430. .MOD_Seiga_Top .list_item_cutout.mod_no_trim a {
  431. height: 100%;
  432. width: 100%;
  433. }
  434. .MOD_Seiga_Top .list_item_cutout.mod_no_trim.large a .illust_info {
  435. bottom: 0px !important;
  436. background-color: rgba(60, 60, 60, 1);
  437. padding: 10px 40px;
  438. }
  439. .MOD_Seiga_Top .list_item_cutout.mod_no_trim.large {
  440. width: 190px;
  441. height: 190px;
  442. }
  443. .MOD_Seiga_Top .rank_box .item_list.mod_no_trim .more_link a {
  444. width: 190px;
  445. }
  446.  
  447. {* タグ検索時、カウンタなどが常時見えるように修正 *}
  448. .MOD_Seiga_TagSearch .list_item.large a .illust_count {
  449. opacity: 1;
  450. }
  451. .MOD_Seiga_TagSearch .list_item.large a {
  452. height: 321px;
  453. }
  454. .MOD_Seiga_TagSearch .list_item.large {
  455. height: 351px;
  456. }
  457.  
  458. {* タイトルと説明文・投稿者アイコンだけコンクリートの地面に置いてあるように感じたので絨毯を敷いた *}
  459. .MOD_Seiga .im_head_bar .inner {
  460. background-color: #FFFFFF;
  461. border-color: #E8E8E8;
  462. border-radius: 5px;
  463. border-style: solid;
  464. border-width: 0 0 1px;
  465. box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
  466. display: block;
  467. margin-top: 20px;
  468. {*margin-bottom: 20px;*}
  469. margin-left: auto;
  470. margin-right: auto;
  471. padding: 15px;
  472. position: relative;
  473. width: 974px;
  474. }
  475.  
  476.  
  477. {* タグの位置調整 *}
  478. .illust_main .mod_tag-top.illust_sub_info {
  479. padding-bottom: 25px;
  480. padding-top: 0;
  481. }
  482.  
  483.  
  484. .illust_sub_info.mod_tag-description-bottom {
  485. margin-top: 15px;
  486. }
  487. .im_head_bar .illust_tag h2 {
  488. float: left;
  489. font-size: 116.7%;
  490. line-height: 120%;
  491. margin: 4px 10px 0 -2px;
  492. overflow: hidden;
  493. }
  494. .im_head_bar .illust_sub_info input#tags {
  495. margin-bottom: 15px;
  496. margin-top: 5px;
  497. padding: 4px 10px;
  498. width: 280px;
  499. }
  500. .im_head_bar .illust_sub_info ul li.btn {
  501. bottom: 15px;
  502. position: absolute;
  503. right: 15px;
  504. }
  505.  
  506. {* タグ右上 *}
  507. .description.mod_tag-description-right {
  508. float: left;
  509. }
  510. .illust_sub_info.mod_tag-description-right {
  511. width: 300px;
  512. float: right;
  513. margin: 0;
  514. }
  515. .mod_tag-description-right .tag {
  516. background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
  517. border: medium none;
  518. margin: 0;
  519. }
  520. .mod_tag-description-right .tag a {
  521. padding: 0 5px;
  522. }
  523. .mod_tag-description-right .tag li {
  524. }
  525. .mod_tag-description-right .tag li a {
  526. padding: 0 5px 0 0;
  527. border: 0;
  528. }
  529. .im_head_bar .illust_sub_info.mod_tag-description-right ul li.btn.active {
  530. }
  531. {* 右下だと被ることがあるので仕方なく *}
  532. .im_head_bar .illust_sub_info.mod_tag-description-right ul li.btn {
  533. display: inline-block;
  534. position: relative;
  535. bottom: auto; right: auto;
  536. }
  537.  
  538. #ichiba_box {
  539. width: 1004px;
  540. margin: 0 auto 20px;
  541. border: 1px solid #ddd;
  542. border-radius: 8px;
  543. }
  544.  
  545. #content.illust { padding: 0; }
  546.  
  547. #related_info .ad_tag { display: none;}
  548.  
  549. {* 右カラム広告のせいで無駄に横スクロールが発生しているのを修正 *}
  550. .related_info .sub_info_side {
  551. overflow-x: hidden;
  552. }
  553.  
  554.  
  555. .illust_main .illust_side .clip.mod_top {
  556. padding: 10px 10px 0;
  557. }
  558.  
  559.  
  560. .MOD_Seiga_FullView #content.illust_big .illust_view_big {
  561. margin: 0 auto;
  562. }
  563.  
  564. .MOD_Seiga_FullView .control {
  565. position: absolute;
  566. right: 0;
  567. top: 0;
  568. z-index: 1000;
  569. opacity: 0;
  570. transition: opacity 0.5s ease;
  571. }
  572.  
  573. .MOD_Seiga_FullView:hover .control {
  574. opacity: 1;
  575. }
  576.  
  577. .MOD_Seiga_FullView .illust_view_big img {
  578. {*transform: scale(1); -webkit-transform: scale(1);
  579. transition: transform 0.3s ease, -webkit-transform 0.3s ease;*}
  580. }
  581.  
  582. .MOD_Seiga_FullView:not(.mod_noScale) .illust_view_big img {
  583. position: absolute;
  584. top: 0;
  585. left: 0;
  586. transform-origin: 0 0 0;
  587. -webkit-transform-origin: 0 0 0;
  588. }
  589.  
  590. .MOD_Seiga_FullView.mod_contain {
  591. overflow: hidden;
  592. }
  593. .MOD_Seiga_FullView.mod_cover {
  594. }
  595. .MOD_Seiga_FullView.mod_contain .illust_view_big img,
  596. .MOD_Seiga_FullView.mod_cover .illust_view_big img {
  597. {*display: none;*}
  598. }
  599.  
  600. .MOD_Seiga_FullView .illust_view_big {
  601. background-repeat: no-repeat;
  602. background-position: center center;
  603. }
  604. .MOD_Seiga_FullView.mod_contain .illust_view_big {
  605. background-size: contain;
  606. }
  607. .MOD_Seiga_FullView.mod_cover .illust_view_big {
  608. background-size: cover;
  609. }
  610.  
  611. .MOD_Seiga .toggleFullScreen {
  612. display: block;
  613. width: 200px;
  614. margin: auto;
  615. transition: 0.4s opacity, 0.4s box-shadow;
  616. }
  617. .MOD_Seiga_FullView .toggleFullScreen {
  618. position: fixed;
  619. top: 0;
  620. left: 0;
  621. z-index: 1000;
  622. margin: 0;
  623. padding: 4px;
  624. cursor: pointer;
  625. border: none;
  626. background: transparent;
  627. color: #0CA5D2;
  628. font-weight: bolder;
  629. }
  630. .MOD_Seiga .toggleFullScreen:hover {
  631. box-shadow: 2px 2px 2px #333;
  632. }
  633.  
  634. .MOD_Seiga_FullView .toggleFullScreen button {
  635. opacity: 0;
  636. margin: 0;
  637. padding: 0;
  638. cursor: pointer;
  639. transition: 0.4s opacity, 0.4s box-shadow;
  640. border: 1px solid #000;
  641. background: #fff;
  642. color: #0CA5D2;
  643. font-weight: bolder;
  644. }
  645. .MOD_Seiga_FullView .toggleFullScreen.show button,
  646. .MOD_Seiga_FullView .toggleFullScreen button:hover {
  647. opacity: 1;
  648. box-shadow: 2px 2px 2px #333;
  649. }
  650. .MOD_Seiga_FullView:fullscreen .toggleFullScreen {
  651. display: none;
  652. }
  653.  
  654. #ko_watchlist_info.mod_hide { display: none !important; }
  655.  
  656. .fullScreenRequestFrame {
  657. position: fixed;
  658. width: 100px;
  659. height: 100px;
  660. left: -999px;
  661. top: -999px;
  662. }
  663.  
  664. .MOD_Seiga_FullView .closeButton {
  665. opacity: 0;
  666. transition: 0.4s opacity ease;
  667. }
  668.  
  669. .MOD_Seiga_FullView .closeButton:hover {
  670. opacity: 1;
  671. }
  672.  
  673. body.fullScreenFrame {
  674. background: #000;
  675. }
  676.  
  677. body.MOD_Seiga_FullView img {
  678. cursor: none;
  679. }
  680.  
  681. body.MOD_Seiga_FullView.mouseMoving img{
  682. cursor: default;
  683. }
  684.  
  685.  
  686. */}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1].replace(/\{\*/g, '/*').replace(/\*\}/g, '*/');
  687.  
  688.  
  689. this.addStyle(__common_css__);
  690.  
  691. if (this.config.get('applyCss')) {
  692. this.addStyle(__css__);
  693. }
  694. },
  695. initializeUserConfig: function() {
  696. var prefix = 'MOD_Seiga_';
  697. var conf = {
  698. applyCss: true,
  699. topUserInfo: true,
  700. tagPosition: 'description-bottom',
  701. noTrim: true,
  702. hidePageTopButton: true,
  703. clipPosition: 'bottom',
  704. hideBottomUserInfo: false
  705. };
  706.  
  707. this.config = {
  708. get: function(key) {
  709. try {
  710. if (window.localStorage.hasOwnProperty(prefix + key)) {
  711. return JSON.parse(window.localStorage.getItem(prefix + key));
  712. }
  713. return conf[key];
  714. } catch (e) {
  715. return conf[key];
  716. }
  717. },
  718. set: function(key, value) {
  719. window.localStorage.setItem(prefix + key, JSON.stringify(value));
  720. }
  721. };
  722. },
  723. initializeBaseLayout: function() {
  724. var $description = $('#content .description, #content .discription').addClass('description');
  725. $('.controll').addClass('control');
  726.  
  727. $('#related_info').after($('#ichiba_box'));
  728.  
  729. if (this.config.get('hideBottomUserInfo') === true) {
  730. $('#ko_watchlist_info').addClass('mod_hide');
  731. }
  732.  
  733. },
  734. initializeScrollTop: function() {
  735. var $document = $(document), $body = $('body'); //, $bar = $('#bar');
  736.  
  737. var reset = this.resetScrollTop = function() {
  738. var nofix = $body.hasClass('nofix');
  739. var commonHeaderHeight = nofix ? 0 : 36; //$bar.outerHeight();
  740. $document.scrollTop(Math.max(
  741. $document.scrollTop(),
  742. $('#content .im_head_bar').offset().top -commonHeaderHeight
  743. ));
  744. };
  745. setTimeout(reset, 100);
  746. reset();
  747. },
  748. initializeDescription: function() {
  749. var $description = $('#content .description, #content .discription, .illust_user_exp');
  750. if ($description.length < 1) { return; }
  751. var html = $description.html();
  752.  
  753. // 説明文中のURLの自動リンク
  754. var linkmatch = /<a.*?<\/a>/, links = [], n;
  755. html = html.split('<br />').join(' <br /> ');
  756. while ((n = linkmatch.exec(html)) !== null) {
  757. links.push(n);
  758. html = html.replace(n, ' <!----> ');
  759. }
  760. html = html.replace(/(https?:\/\/[\x21-\x3b\x3d-\x7e]+)/gi, '<a href="$1" target="_blank" class="otherSite">$1</a>');
  761. for (var i = 0, len = links.length; i < len; i++) {
  762. html = html.replace(' <!----> ', links[i]);
  763. }
  764. html = html.split(' <br /> ').join('<br />');
  765.  
  766. var $desc = $('<div>' + html + '</div>');
  767. $description.empty().append($desc);
  768.  
  769. },
  770. initializeCommentLink: function() {
  771. var videoReg = /((sm|nm|so)\d+)/g;
  772. var seigaReg = /(im\d+)/g;
  773. var bookReg = /((bk|mg)\d+)/g;
  774. var urlReg = /(https?:\/\/[\x21-\x3b\x3d-\x7e]+)/gi;
  775.  
  776. var autoLink = function(text) {
  777. text = text
  778. .replace(videoReg, '<a href="//www.nicovideo.jp/watch/$1" class="video mod_link">$1</a>')
  779. .replace(seigaReg, '<a href="/seiga/$1" class="illust mod_link">$1</a>')
  780. .replace(bookReg, '<a href="/watch/$1" class="book mod_link">$1</a>')
  781. .replace(urlReg, '<a href="$1" target="_blank" class="otherSite mod_link">$1</a>');
  782. return text;
  783. };
  784. var commentLink = function(selector) {
  785. $(selector).each(function() {
  786. var $this = $(this);
  787. var html = $this.html(), linked = autoLink(html);
  788. if (html !== linked) {
  789. $this.html(linked);
  790. }
  791. $this.addClass('mod_linked');
  792. });
  793. };
  794.  
  795. setTimeout(function() {
  796. commentLink('#comment_list .comment_info .text:not(.mod_linked)');
  797. var updateTimer = null;
  798. document.body.addEventListener('DOMNodeInserted', function(e) {
  799. if (e.target.className && e.target.className.indexOf('comment_list_item') >= 0) {
  800. if (updateTimer) {
  801. updateTimer = clearTimeout(updateTimer);
  802. }
  803. updateTimer = setTimeout(function() {
  804. updateTimer = clearTimeout(updateTimer);
  805. commentLink('#comment_list .comment_info .text:not(.mod_linked)');
  806. //var $text = $(e.target).find('.text');
  807. //if (!$text.hasClass('mod_linked')) $text.html(autoLink($text.text())).addClass('mod_linked');
  808. }, 100);
  809. }
  810. });
  811.  
  812. }, 100);
  813. },
  814. initializeThumbnail: function() {
  815. if (this.config.get('noTrim') !== true) { return; }
  816.  
  817. var treg = /^(http:\/\/lohas.nicoseiga.jp\/+thumb\/+.\d+)([a-z\?]*)/;
  818. var noTrim = function() {
  819. $('.list_item_cutout, #main .list_item:not(.mod_no_trim)').each(function() {
  820. var $this = $(this);
  821. var $thum = $this.find('.thum');
  822. var $img = $thum.find('img');
  823. var src = $img.attr('src') || '';
  824. if ($thum.length * $img.length < 1 || !treg.test(src)) return;
  825. // TODO: 静画のサムネの種類を調べる
  826. var url = RegExp.$1 + 'q?';//RegExp.$2 === 't' ? src : RegExp.$1 + 'q?';
  827. $thum.css({'background-image': 'url("' + url + '")'});
  828. $this.addClass('mod_no_trim');
  829. });
  830. };
  831. noTrim();
  832. document.body.addEventListener('AutoPagerize_DOMNodeInserted', function() {
  833. setTimeout(function() {
  834. noTrim();
  835. }, 500);
  836. });
  837. },
  838. initializePageTopButton: function() {
  839. $('body').toggleClass('mod_hidePageTopButton', this.config.get('hidePageTopButton'));
  840. },
  841. initializeKnockout: function() {
  842. },
  843. initializeFullScreenRequest: function() {
  844. var $body = $('body');
  845. var $iframe = $('<iframe allowfullscreen="on" class="fullScreenRequestFrame" name="fullScreenRequestFrame"></iframe>');
  846.  
  847. $body.append($iframe);
  848.  
  849. var $fullScreenButton = $([
  850. '<button class="toggleFullScreen btn normal" title="フルスクリーン表示に切り換えます(Fキー)">',
  851. '<span>フルスクリーン</span>',
  852. '</button>',
  853. ''].join(''));
  854. $('.illust_main .illust_wrapper .inner .thum_large:first').append($fullScreenButton);
  855. var toggleFullScreen = $.proxy(function() {
  856. if (this.fullScreen.now()) {
  857. this.fullScreen.cancel();
  858. } else {
  859. $iframe[0].contentWindow.location.replace($('#illust_link').attr('href'));
  860. this.fullScreen.request($iframe[0]);
  861. }
  862. }, this);
  863. $fullScreenButton.on('click', function(e) {
  864. e.preventDefault();
  865. e.stopPropagation();
  866. toggleFullScreen();
  867. });
  868.  
  869. var onMessage = function(event) {
  870. if (event.origin.indexOf('nicoseiga.jp') < 0) return;
  871. try {
  872. var data = JSON.parse(event.data);
  873. if (data.id !== 'MOD_Seiga') { return; }
  874. if (data.command === 'toggleFullScreen') {
  875. console.log('3');
  876. toggleFullScreen();
  877. }
  878. } catch (e) {
  879. console.log('Exception', e);
  880. console.trace();
  881. }
  882. };
  883.  
  884. window.addEventListener('message', onMessage);
  885. $body.on('keydown.watchItLater', function(e) {
  886. if (e.target.tagName === 'SELECT' || e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') {
  887. return;
  888. }
  889. if (e.keyCode === 70) { // F
  890. toggleFullScreen();
  891. }
  892. });
  893.  
  894. },
  895. initializeOther: function() {
  896. $('body').addClass('MOD_Seiga');
  897. },
  898. initializeSettingPanel: function() {
  899. var $menu = $('<li class="MOD_SeigaSettingMenu"><a href="javascript:;" title="MOD_Seigaの設定変更">MOD_Seiga設定</a></li>');
  900. var $panel = $('<div id="MOD_SeigaSettingPanel" />');//.addClass('open');
  901. var $button = $('<button class="toggleSetting playerBottomButton">設定</botton>');
  902.  
  903. $button.on('click', function(e) {
  904. e.stopPropagation(); e.preventDefault();
  905. $panel.toggleClass('open');
  906. });
  907.  
  908. var config = this.config;
  909. $menu.find('a').on('click', function() { $panel.toggleClass('open'); });
  910.  
  911. var __tpl__ = (function() {/*
  912. <div class="panelHeader">
  913. <h1 class="windowTitle">MOD_Seigaの設定</h1>
  914. <p>設定はリロード後に反映されます</p>
  915. <button class="close" title="閉じる">×</button>
  916. </div>
  917. <div class="panelInner">
  918. <!--<div class="item" data-setting-name="topUserInfo" data-menu-type="radio">
  919. <h3 class="itemTitle">投稿者情報を右上に移動 </h3>
  920. <label><input type="radio" value="true" > する</label>
  921. <label><input type="radio" value="false"> しない</label>
  922. </div>-->
  923.  
  924. <div class="item" data-setting-name="noTrim" data-menu-type="radio">
  925. <h3 class="itemTitle">サムネイルの左右カットをやめる </h3>
  926. <label><input type="radio" value="true" >やめる</label>
  927. <label><input type="radio" value="false">やめない</label>
  928. </div>
  929.  
  930. <div class="item" data-setting-name="hidePageTopButton" data-menu-type="radio">
  931. <h3 class="itemTitle">ウィンドウ幅が狭いときはページトップに戻るボタンを隠す</h3>
  932. <label><input type="radio" value="true" >隠す</label>
  933. <label><input type="radio" value="false">隠さない</label>
  934. </div>
  935.  
  936. <div class="item" data-setting-name="hideBottomUserInfo" data-menu-type="radio">
  937. <h3 class="itemTitle">ページ下側の投稿者情報を隠す</h3>
  938. <small>右上だけでいい場合など</small><br>
  939. <label><input type="radio" value="true" >隠す</label>
  940. <label><input type="radio" value="false">隠さない</label>
  941. </div>
  942.  
  943. <div class="item" data-setting-name="clipPosition" data-menu-type="radio">
  944. <h3 class="itemTitle">クリップ登録メニューの位置(旧verのみ)</h3>
  945. <label><input type="radio" value="&quot;top&quot;" >上</label>
  946. <label><input type="radio" value="&quot;bottom&quot;">下</label>
  947. </div>
  948. <!--
  949. <div class="item" data-setting-name="tagPosition" data-menu-type="radio">
  950. <h3 class="itemTitle">タグの位置(旧verのみ) </h3>
  951. <label><input type="radio" value="&quot;description-bottom&quot;">説明文の下</label>
  952. <label><input type="radio" value="&quot;description-right&quot;">説明文の右</label>
  953. <label><input type="radio" value="&quot;top&quot;">画像の上</label>
  954. <label><input type="radio" value="&quot;default&quot;">画像の下(標準)</label>
  955. </div>
  956. -->
  957.  
  958. <div class="expert">
  959. <h2>上級者向け設定</h2>
  960. </div>
  961. <div class="item" data-setting-name="applyCss" data-menu-type="radio">
  962. <h3 class="itemTitle">MOD_Seiga標準のCSSを使用する</h3>
  963. <small>他のuserstyleを使用する場合は「しない」を選択してください</small><br>
  964. <label><input type="radio" value="true" > する</label>
  965. <label><input type="radio" value="false"> しない</label>
  966. </div>
  967. </div>
  968. */}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1].replace(/\{\*/g, '/*').replace(/\*\}/g, '*/');
  969. $panel.html(__tpl__);
  970. $panel.find('.item').on('click', function(e) {
  971. var $this = $(this);
  972. var settingName = $this.attr('data-setting-name');
  973. var value = JSON.parse($this.find('input:checked').val());
  974. console.log('seting-name', settingName, 'value', value);
  975. config.set(settingName, value);
  976. }).each(function(e) {
  977. var $this = $(this);
  978. var settingName = $this.attr('data-setting-name');
  979. var value = config.get(settingName);
  980. $this.addClass(settingName);
  981. $this.find('input').attr('name', settingName).val([JSON.stringify(value)]);
  982. });
  983. $panel.find('.close').click(function() {
  984. $panel.removeClass('open');
  985. });
  986.  
  987.  
  988. $('#siteHeaderRightMenuFix').after($menu);
  989. $('body').append($panel);
  990. },
  991. initializeFullscreenImage: function() {
  992. var $body = $('body'), $container = $('.illust_view_big'), $img = $container.find('img'), scale = 1;
  993. var $fullScreenButton = $([
  994. '<div class="toggleFullScreen show">',
  995. '<button title="フルスクリーン表示に切り換えます">',
  996. '<span>フルスクリーン</span>',
  997. '</button>',
  998. '</div>',
  999. ''].join(''));
  1000. var $window = $(window);
  1001. $('.controll').addClass('control');
  1002.  
  1003. var clearCss = function() {
  1004. $body.removeClass('mod_contain mod_cover mod_noScale');
  1005. $container.css({width: '', height: ''});
  1006. $img.css({'transform': '', '-webkit-transform': '', top: '', left: ''});
  1007. };
  1008.  
  1009. // ウィンドウの内枠フィット (画面におさまる範囲で最大化)
  1010. var contain = function() {
  1011. clearCss();
  1012. $body.addClass('mod_contain');
  1013. scale = Math.min(
  1014. $window.innerWidth() / $img.outerWidth(),
  1015. $window.innerHeight() / $img.outerHeight()
  1016. );
  1017. scale = Math.min(scale, 10);
  1018. $img.css({
  1019. 'transform': 'scale(' + scale + ')',
  1020. '-webkit-transform': 'scale(' + scale + ')',
  1021. 'left': ($window.innerWidth() - $img.outerWidth() * scale) / 2 + 'px',
  1022. 'top': ($window.innerHeight() - $img.outerHeight() * scale) / 2 + 'px'
  1023. });
  1024. $container.width($window.innerWidth());
  1025. $container.height($window.innerHeight());
  1026. // $container.css('background-image', 'url("' + $img.attr('src') + '")');
  1027. };
  1028.  
  1029. // ウィンドウの外枠フィット
  1030. var cover = function() {
  1031. clearCss();
  1032. $body.addClass('mod_cover').css('overflow', 'scroll');
  1033. scale = Math.max(
  1034. $window.innerWidth() / $img.outerWidth(),
  1035. $window.innerHeight() / $img.outerHeight()
  1036. );
  1037. scale = Math.min(scale, 10);
  1038. $img.css({
  1039. 'transform': 'scale(' + scale + ')',
  1040. '-webkit-transform': 'scale(' + scale + ')',
  1041. });
  1042. // ウィンドウサイズの計算にスクロールバーの幅を含めるための措置 おもにwindows用
  1043. $body.css('overflow', '');
  1044. };
  1045.  
  1046. // 原寸大表示
  1047. var noScale = function() {
  1048. clearCss();
  1049. $body.addClass('mod_noScale');
  1050. scale = 1;
  1051. $container.css('background-image', '');
  1052. };
  1053.  
  1054. // クリックごとに表示を切り替える処理
  1055. var onClick = function(e) {
  1056. if (e.button > 0) { return; }
  1057. // TODO: クリックした位置が中心になるようにスクロール
  1058. if ($body.hasClass('mod_noScale')) {
  1059. contain();
  1060. } else
  1061. if ($body.hasClass('mod_contain')) {
  1062. cover();
  1063. } else {
  1064. noScale();
  1065. }
  1066. };
  1067. // ウィンドウがリサイズされた時などの再計算用
  1068. var update = function() {
  1069. if ($body.hasClass('mod_contain')) {
  1070. contain();
  1071. } else
  1072. if ($body.hasClass('mod_cover')) {
  1073. cover();
  1074. }
  1075. };
  1076.  
  1077. // モニターいっぱい表示を切り換える
  1078. var toggleFullScreen = $.proxy(function() {
  1079. if (window.name === 'fullScreenRequestFrame') {
  1080. parent.postMessage(JSON.stringify({
  1081. id: 'MOD_Seiga',
  1082. command: 'toggleFullScreen'
  1083. }),
  1084. 'http://seiga.nicovideo.jp');
  1085. return;
  1086. }
  1087.  
  1088. if (this.fullScreen.now()) {
  1089. this.fullScreen.cancel(document.documentElement);
  1090. } else {
  1091. this.fullScreen.request(document.documentElement);
  1092. }
  1093. }, this);
  1094.  
  1095. window.setTimeout($.proxy(function() {
  1096. $fullScreenButton.removeClass('show');
  1097. }, this), 2000);
  1098.  
  1099. // /seiga/imXXXXXXからiframeで呼ばれてる時の処理
  1100. if (window.name === 'fullScreenRequestFrame') {
  1101. $('img[src$="btn_close.png"]')
  1102. .addClass('closeButton')
  1103. .off()
  1104. .on('click', function() {
  1105. toggleFullScreen();
  1106. });
  1107. $('body').addClass('fullScreenFrame');
  1108. }
  1109.  
  1110. $fullScreenButton.on('click', function(e) {
  1111. e.preventDefault();
  1112. e.stopPropagation();
  1113. toggleFullScreen();
  1114. });
  1115. $body.append($fullScreenButton);
  1116.  
  1117.  
  1118. // マウスを動かさない時はカーソルを消す
  1119. var mousemoveStopTimer = null;
  1120. var showMouseNsec = function() {
  1121. $body.addClass('mouseMoving');
  1122. if (mousemoveStopTimer) {
  1123. window.clearTimeout(mousemoveStopTimer);
  1124. mousemoveStopTimer = null;
  1125. }
  1126. mousemoveStopTimer = window.setTimeout(function() {
  1127. $body.removeClass('mouseMoving');
  1128. mousemoveStopTimer = null;
  1129. }, 1000);
  1130. };
  1131. $body
  1132. .on('mousemove.MOD_Seiga', showMouseNsec)
  1133. .on('mousedown.MOD_Seiga', showMouseNsec);
  1134.  
  1135.  
  1136. contain();
  1137. $img.on('click', onClick);
  1138. $window.on('resize', update);
  1139. $img.on('load.MOD_Seiga', $.proxy(function() {
  1140. this.initializePrintCss($img.clone());
  1141. contain();
  1142. $img.off('load.MOD_Seiga');
  1143. }, this));
  1144.  
  1145.  
  1146. // おもにwindows等、縦ホイールしかない環境で横スクロールしやすくする
  1147. // Firefoxでうまくいかない
  1148. var hasWheelDeltaX = false;
  1149. $(document).on('mousewheel', function(e) {
  1150. var delta = 0;
  1151.  
  1152. if ($body.hasClass('mod_contain')) { return; }
  1153.  
  1154. if (document.body.scrollHeight > window.innerHeight) { return; }
  1155.  
  1156. if (hasWheelDeltaX) { return; }
  1157.  
  1158. if (!e.originalEvent) { return; }
  1159. var oe = e.originalEvent;
  1160.  
  1161. if (typeof oe.wheelDelta === 'number') {
  1162. if (typeof oe.wheelDeltaX === 'number' && oe.wheelDeltaX !== 0) {
  1163. hasWheelDeltaX = true;
  1164. return; // ホイールで横スクロールできる環境だとかえって邪魔なのでなにもしない
  1165. }
  1166.  
  1167. delta = e.originalEvent.wheelDelta / Math.abs(e.originalEvent.wheelDelta);
  1168. }
  1169. if (delta === 0) return;
  1170.  
  1171. e.preventDefault();
  1172. e.stopPropagation();
  1173.  
  1174. var scrollLeft = $body.scrollLeft() - (delta * $window.innerWidth() / 10);
  1175. $body.scrollLeft(Math.max(scrollLeft, 0));
  1176. });
  1177. },
  1178. initializePrintCss: function($img) {
  1179. this.initializePrintCss = function() {};
  1180. var self = this;
  1181.  
  1182. $img.css({
  1183. width: 'auto', height: 'auto',
  1184. transform: '', left: '100%', top: '100%', opacity: 0, position: 'fixed'
  1185. });
  1186.  
  1187. var $body = $('body');
  1188. $body.append($img);
  1189.  
  1190. window.setTimeout(function() {
  1191. var width = $img.outerWidth(), height = $img.outerHeight();
  1192. $img.remove();
  1193.  
  1194. // TODO: 用紙サイズ変更
  1195. var paperMarginV = 0.1; // 19; // 紙送りマージン?
  1196. var imageRatio = height / Math.max(width, 1);
  1197. var paperRatio = (A4_HEIGHT - paperMarginV) / A4_WIDTH;
  1198. var landscapeRatio = (A4_WIDTH - paperMarginV) / A4_HEIGHT;
  1199. var isLandscape =
  1200. Math.abs(paperRatio - imageRatio) > Math.abs(landscapeRatio - imageRatio);
  1201.  
  1202. paperRatio = isLandscape ? landscapeRatio : paperRatio;
  1203.  
  1204. var isFitV = paperRatio < imageRatio;
  1205. var paperWidth = isLandscape ? A4_HEIGHT : A4_WIDTH;
  1206. var paperHeight = (isLandscape ? A4_WIDTH : A4_HEIGHT) - paperMarginV;
  1207. var marginLeft = 0, marginTop = 0, imageWidth = paperWidth, imageHeight = paperHeight;
  1208.  
  1209. if (isFitV) { // タテ合わせ
  1210. imageWidth = paperHeight / imageRatio;
  1211. marginLeft = (paperWidth - imageWidth) / 2;
  1212. } else { // ヨコ合わせ
  1213. imageHeight = paperWidth * imageRatio;
  1214. marginTop = (paperHeight - imageHeight) / 2;
  1215. }
  1216. var css = [
  1217. '@media print {\n',
  1218. '.MOD_Seiga_FullView .illust_view_big img {\n ',
  1219. 'margin-left: ', marginLeft, 'mm; ',
  1220. 'margin-top: ', marginTop, 'mm; ',
  1221. 'width:', imageWidth, 'mm !important; ',
  1222. 'height:', imageHeight, 'mm !important;',
  1223. '\n}\n',
  1224. '}',
  1225. ].join('');
  1226.  
  1227. //console.log('paper?', paperWidth, paperHeight, imageWidth, imageHeight);
  1228. //console.log('ratio?', width, height, isLandscape, paperRatio, imageRatio);
  1229. //console.log('print css', css);
  1230.  
  1231. self._printCss = self.addStyle(css, 'MOD_Seiga_print');
  1232. $body
  1233. .toggleClass('landscape', isLandscape)
  1234. .toggleClass('fitV', isFitV);
  1235. }, 100);
  1236. }
  1237. };
  1238.  
  1239. window.MOD_Seiga.initialize();
  1240.  
  1241. });
  1242.  
  1243. var script = document.createElement("script");
  1244. script.id = "MOD_SeigaLoader";
  1245. script.setAttribute("type", "text/javascript");
  1246. script.setAttribute("charset", "UTF-8");
  1247. script.appendChild(document.createTextNode("(" + monkey + ")()"));
  1248. document.body.appendChild(script);
  1249.  
  1250. })();

QingJ © 2025

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