今年一定島 只開啟一個webm影片

汲汲營營大報社

  1. // ==UserScript==
  2. // @name 今年一定島 只開啟一個webm影片
  3. // @description 汲汲營營大報社
  4. // @author 稻米
  5. // @namespace https://greasyfork.org/zh-TW/scripts/389589
  6. // @version 2024.07.27.0010.build16299
  7.  
  8. // @match *://gaia.komica.org/00b/*
  9. // @match *://gaia.komica1.org/00b/*
  10. // @match *://gaia.komica2.cc/00b/*
  11. // @match *://gita.komica1.org/00b/*
  12.  
  13.  
  14. // @exclude *://*/00b/src/*
  15. // @exclude *://*/00b/thumb/*
  16.  
  17. // @grant none
  18. // @license WTFPL
  19.  
  20.  
  21. // ==/UserScript==
  22.  
  23.  
  24.  
  25.  
  26.  
  27. //jquery
  28. try{}
  29. catch(err){}
  30. finally{}
  31. //throw "stop";
  32.  
  33. $(document).ready(function() {
  34. //console.log( 'jquery ready' );
  35. //全域變數//global
  36. //window.var190830=[];
  37. //$.gginin=window.gg;
  38. var FFF='';
  39. FFF=$('#postform');
  40. //console.log( FFF );
  41. var cc=0;
  42. if(FFF.length>0){cc=cc+1;}
  43. //
  44. if(cc >0){
  45. poi();
  46. }
  47. //
  48.  
  49. });
  50.  
  51. function poi230120收起影片(in1){//收起影片
  52. //console.log( 'poi230120' );
  53. //console.log( in1 );
  54. var time=in1;
  55. var FFF;
  56. //
  57. var aa3=$('video');//全部的video
  58. aa3.each(function( index,item ) {
  59. //console.log( index,item );//video
  60. //var aa2a=$(item).parent().find('.expanded-close.text-button');//寫著收回的按鈕
  61. var aa2a=$(item);//.parents(); 跟 parent() 不同
  62. //console.log( aa2a );//寫著收回的按鈕
  63. if($(item).attr('poi210530')==time){
  64. //console.log('yy');
  65. //沒事
  66. }else{
  67. //console.log('nn');
  68. //console.log('收起影片');
  69. FFF=$(item).parent().find('.expanded-close.text-button');//寫著收回的按鈕
  70. //console.log( FFF );
  71. //FFF.click();//收起影片 不要用原生收合按鈕 位置會跑掉
  72. //
  73. //手刻模擬收合
  74. FFF=$(item).parent().prev();//被隱藏的縮圖
  75. //console.log(FFF);
  76. //讓縮圖顯示
  77. FFF.css({'display':'inline',});
  78. FFF=$(item).parent();//動態新增的元素
  79. //console.log('動態新增的元素',FFF);
  80. FFF.remove();//移除
  81.  
  82. }
  83. });
  84.  
  85. }//poi230120()
  86.  
  87. function poi230120是否靜音(in1){//切換靜音
  88. var 目標元素=in1;//點縮圖後產生的video
  89. //console.log('poi230120切換靜音');
  90. //
  91. var json;
  92. var FFF;
  93.  
  94. //影片開啟聲音的手動控制
  95. var aa2=$(目標元素).prev().find('span');//點縮圖後產生的收合按鈕 //動態元素
  96. aa2.css({
  97. "background-color":"yellow",
  98. "border":"1px solid #000",
  99. });//連結上背景色 不想上色就把這段刪除
  100. var str='<span class="poi230120mute">🔕</span>';
  101. FFF=aa2.parent().append( str );
  102. //console.log( FFF );//.parent() //
  103. $('.poi230120mute').css({
  104. "background-color":"yellow",
  105. "border":"1px solid #000",
  106. 'cursor':'pointer',
  107. });//連結上背景色 不想上色就把這段刪除
  108.  
  109. //
  110. //aa[0].muted=false;//解除靜音
  111. //aa.prop('muted', false);//解除靜音
  112. //aa[0].volume = 0.5;//設定音量
  113.  
  114. //console.log( FFF );
  115. //localStorage.setItem('image', 'myCat.png');
  116. //localStorage.removeItem('image');
  117. //window.localStorage.removeItem('poi230120');
  118. //console.log( '重置' );
  119.  
  120.  
  121. //FFF=window.localStorage.poi230120;
  122. //console.log( FFF );
  123.  
  124. //初始化資料 1=有聲音 0=沒聲音
  125. FFF=window.localStorage.getItem('poi230120');
  126. //FFF=window.localStorage.poi230120;
  127. //console.log( FFF );
  128.  
  129. var 是否重新建立=0;
  130.  
  131. if( FFF === null ){ //沒有資料=建立第一次的資料
  132. console.log( '沒有資料' );
  133. 是否重新建立=1;
  134. }//if
  135. //FFF=window.localStorage.getItem('poi230120');
  136. //
  137. try{
  138. json = JSON.parse( FFF );//字串轉json
  139. if( json.版本 != 100 ){//檢查版本
  140. 是否重新建立=1;
  141. }//if
  142. }catch(e){
  143. //有錯誤會跑到這邊
  144. console.log( e );
  145. //throw "json讀取失敗";
  146. 是否重新建立=1;
  147. }finally{
  148. console.log( 'try-catch檢查點' );
  149. }
  150. //
  151.  
  152. if( 是否重新建立==1 ){
  153. console.log( '資料重新建立' );
  154. window.localStorage.removeItem('poi230120');//拋棄舊版本資料
  155. var 初始資料json字串=`{"版本":100,"是否靜音":1,"音量":1,"陣列":["bb1","bb2"]}`;
  156. window.localStorage.poi230120=初始資料json字串; //寫入初始資料
  157. //重新讀取
  158. }//if
  159.  
  160. //FFF=window.localStorage.poi230120;
  161. FFF=window.localStorage.getItem('poi230120');
  162. json = JSON.parse( FFF );//讀取 //字串轉json
  163. //console.log( json );//讀取
  164.  
  165.  
  166. //讀取json內容設置是否靜音
  167. if( json.是否靜音 ==1 ){
  168. 目標元素.muted=true;//靜音
  169. $('.poi230120mute').text('🔕');
  170. }else{
  171. 目標元素.muted=false;//解除靜音
  172. $('.poi230120mute').text('🔔');
  173. }//if
  174.  
  175. //點擊鈴鐺 切換靜音狀態
  176. $('.poi230120mute').on('click',function(e){
  177. console.log('click鈴鐺');
  178. FFF=window.localStorage.poi230120;
  179. json = JSON.parse( FFF );
  180. //console.log( json );
  181. //console.log( json.是否靜音 );
  182. //
  183. if(json.是否靜音==1){//切換狀態
  184. //1->0
  185. //console.log( 'json.是否靜音==1' );
  186. json.是否靜音=0;
  187. }else{
  188. //0->1
  189. json.是否靜音=1;
  190. }
  191. //
  192.  
  193. if( json.是否靜音==1 ){ //根據鈴鐺狀態改變音量
  194. //1=靜音
  195. 目標元素.muted=true;//靜音
  196. $('.poi230120mute').text('🔕');
  197. }else{
  198. //0=有聲
  199. 目標元素.muted=false;//解除靜音
  200. $('.poi230120mute').text('🔔');
  201. if(目標元素.volume == 0){
  202. 目標元素.volume=0.5;
  203. }
  204. }//if
  205.  
  206. json.音量=this.volume;
  207. //console.log( json );
  208. let json_str=JSON.stringify(json);
  209. window.localStorage.poi230120=json_str;//寫入
  210.  
  211. });//on=click
  212. /*
  213. //解除靜音 但音量被設置=0的情況 調整音量=50%
  214. if( 目標元素.volume == 0 ){
  215. 目標元素.volume = 0.5;
  216. }
  217. //音量被設置=0的情況 嘗試解除靜音 便調整音量=50%
  218. if( this.muted ==0 ){
  219. this.volume=0.5;
  220. json.是否靜音=0;
  221. }
  222.  
  223. */
  224.  
  225.  
  226.  
  227.  
  228. //return;
  229. //監視音量改變 同步更改鈴鐺的狀態
  230. $(目標元素).on('volumechange', function() {
  231. console.log( '靜音狀態='+this.muted, '音量='+this.volume );
  232. FFF=window.localStorage.poi230120;
  233. json = JSON.parse( FFF );//讀取
  234. //console.log( json );
  235. //
  236. //return;
  237.  
  238. if(this.muted){
  239. //1=靜音
  240. json.是否靜音=1;
  241. }else{
  242. //0=有聲
  243. json.是否靜音=0;
  244. }//if
  245. //特例//音量=0
  246. if( this.volume == 0 ){
  247. //靜音=音量0
  248. json.是否靜音=1;
  249. //this.muted=1;
  250. }else{
  251. //有聲
  252. }//if
  253.  
  254. //console.log('json.是否靜音', json.是否靜音 );
  255.  
  256. if( json.是否靜音==1 ){
  257. //靜音
  258. 目標元素.muted=true;//靜音
  259. $('.poi230120mute').text('🔕');
  260. }else{
  261. //有聲
  262. 目標元素.muted=false;//解除靜音
  263. $('.poi230120mute').text('🔔');
  264.  
  265. }
  266. //
  267. json.音量=this.volume;
  268. //console.log( json );
  269. let json_str=JSON.stringify(json);
  270. window.localStorage.poi230120=json_str;//寫入
  271. });//on=volumechange
  272.  
  273. }//poi230120是否靜音
  274.  
  275. function poi230120影片置頂(in1){//影片置頂
  276. //console.log( '影片置頂' );
  277. //點開影片後將影片位置置頂
  278. var 目標元素=in1;
  279. var FFF;
  280.  
  281. console.log( 目標元素 );
  282.  
  283. //aa.one( "loadedmetadata " ,function(event){
  284.  
  285. 目標元素.one("timeupdate",function(event){ //只執行一次的on 開始撥放就置頂
  286. console.log( '影片置頂' );
  287. //console.log( this.currentTime , this.duration );//現在播放的時間點 //影片全長
  288.  
  289. FFF=$(this).parent().parent();
  290. //console.log( FFF );
  291. //FFF=FFF.find('.post-head');
  292. FFF=FFF.attr('id');
  293. //console.log( FFF );
  294. window.location.hash='#'+FFF;//取得id位置
  295.  
  296. //FFF=FFF.prop('offsetTop');//取得捲軸位置
  297. //$(document).scrollTop(FFF);//捲軸移動到video的開頭???
  298. });
  299.  
  300. 目標元素.one( "progress" ,function(event){
  301. //console.log( "progress" );
  302. });
  303. }
  304.  
  305. function poi(){
  306. var FFF;
  307. var aa0=$('.file-thumb');
  308. //console.log( aa0 );
  309. //$('.file-thumb').on('click',function(e){//.file-thumb綁自己 //沒綁到動態元素
  310. $('body').on('click','.file-thumb',function(e){//body綁.file-thumb //有綁到展開後的動態元素
  311. //console.log('click .file-thumb'); //ok
  312. //
  313. //從附檔名過濾出webm
  314. FFF=$(this).parent();//縮圖&影片所在的留言位置
  315. //console.log(FF);
  316. FFF=FFF.find('.file-text').text();//檔名 //純文字
  317. FFF=FFF.includes("webm");
  318. //console.log( FFF ); //ture
  319. if(FFF){
  320. //console.log( 'yy' ); //ture
  321. //沒事
  322. }else{
  323. //不是影片
  324. return 0;//結束
  325. }
  326.  
  327.  
  328.  
  329.  
  330. //標記點擊的影片
  331. var aa=$(this).next().find('video');//點縮圖後產生的video //動態元素
  332.  
  333. aa.css({
  334. "max-width": "640px",
  335. "max-height": "640px",
  336. "min-width": "360px",
  337. "min-height": "360px",
  338. "width": "auto",
  339. "height": "auto",
  340. //'border-right':'5px solid #F0F',
  341. 'box-shadow':'5px 10px 0px 0px #F0F',
  342. });//影片的最大長寬
  343. var time=Date.now();//時間戳
  344. //console.log('新的時間='+time);
  345. aa.attr('poi210530',time);//給影片元素新增標籤
  346. //console.log(aa[0]);//
  347.  
  348. //多個影片收合
  349. poi230120收起影片(time);//多個影片收合
  350. poi230120影片置頂(aa);//先收合其他影片 再置頂
  351.  
  352.  
  353. //return 0;
  354.  
  355. poi230120是否靜音( aa[0] );
  356.  
  357. //return 0;
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371. });
  372. }
  373.  
  374.  
  375.  
  376. /*
  377. 展開後的動態元素 不能綁定事件?
  378.  
  379. */