twitcasting_collapse_comment

ツイキャスのコメント欄を非表示にする。

当前为 2020-01-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name twitcasting_collapse_comment
  3. // @namespace http://catherine.v0cyc1pp.com/twitcasting_collapse_comment.user.js
  4. // @include http://twitcasting.tv/*
  5. // @include https://twitcasting.tv/*
  6. // @include https://ssl.twitcasting.tv/*
  7. // @exclude https://twitcasting.tv/
  8. // @exclude https://twitcasting.tv/?*
  9. // @version 1.7
  10. // @require http://code.jquery.com/jquery-3.4.1.min.js
  11. // @grant none
  12. // @run-at document-end
  13. // @description ツイキャスのコメント欄を非表示にする。
  14. // ==/UserScript==
  15.  
  16. this.$ = this.jQuery = jQuery.noConflict(true);
  17.  
  18.  
  19. console.log("twitcasting_collapse_comment start");
  20.  
  21.  
  22.  
  23. function main() {
  24. //console.log("main() start");
  25.  
  26. // すでに処理済ならなにもしない
  27. /*
  28. var tmp = $(".header_twitcasting_collapse_comment");
  29. console.log("tmp="+tmp);
  30. if (tmp != null) {
  31. return;
  32. }
  33. */
  34. if ( $(".header_twitcasting_collapse_comment").length ) {
  35. return;
  36. }
  37.  
  38.  
  39. // 隠すブロックの前に「コメントエリア (クリックで展開)」のヘッダをつける。
  40. $("div.tw-player-page__comment__list").before("<div class=\"header_twitcasting_collapse_comment\" style=\"text-align: center;cursor: hand; cursor: pointer;\"><span>コメントエリア (クリックで展開)</span>");
  41.  
  42. // 隠すブロックをデフォルトで非表示にする。
  43. $("div.tw-player-page__comment__list").attr("style","display:none;clear:both;");
  44.  
  45. $(".header_twitcasting_collapse_comment").click(function () {
  46.  
  47. var $header = $(this);
  48. //getting the next element
  49. var $content = $header.next();
  50. //open up the content needed - toggle the slide- if visible, slide up, if not slidedown.
  51.  
  52.  
  53. $content.slideToggle(200);
  54.  
  55.  
  56. /* ヘッダのテキストを変更する場合
  57. $content.slideToggle(500, function () {
  58. //execute this after slideToggle is done
  59. //change text of header based on visibility of content div
  60. $header.text(function () {
  61. //change text based on condition
  62. return $content.is(":visible") ? "Collapse" : "Expand";
  63. });
  64. });
  65. */
  66. });
  67. }
  68.  
  69. var observer = new MutationObserver(function(mutations) {
  70. observer.disconnect();
  71. main();
  72. observer.observe( document, config);
  73. });
  74. var config = { attributes: false, childList: true, characterData: false, subtree:true };
  75. observer.observe( document, config);

QingJ © 2025

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