halihali便携按钮

快速上一集下一集,快速跳到指定位,窗口化全屏功能,切源功能。

  1. // ==UserScript==
  2. // @license MIT
  3. // @name halihali便携按钮
  4. // @namespace 哈哩哈哩快速操作按钮
  5. // @description 快速上一集下一集,快速跳到指定位,窗口化全屏功能,切源功能。
  6. // @version 2.1
  7. // @author You
  8. // @match http://*/*
  9. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  10. // @grant unsafeWindow
  11. // @grant GM_setValue
  12. // @grant GM_getValue
  13. // @grant GM_deleteValue
  14. // @grant GM_addValueChangeListener
  15.  
  16.  
  17.  
  18. // ==/UserScript==
  19.  
  20. (function () {
  21. 'use strict';
  22.  
  23. //层key关键id
  24. // key: C1
  25. // key: C2
  26. // key: C3
  27.  
  28. /*
  29. 全自动流程 1.进入C2表示切换集数,自动全屏,自动跳片头,自动跳片尾
  30.  
  31. 1.层1-层2切换源 C1-C2.VideoResNext
  32. 2.层1-层3跳片头 C1-C3.VdoProgressSet
  33. 3.层3-层1自动下一集 C3-C1.NextVideo
  34. 4.
  35.  
  36. */
  37. let url = location.hostname;
  38.  
  39. console.log("0.标签↓. " + url);
  40.  
  41.  
  42. if(url.indexOf("hali") != -1){
  43. //----------------------------------AD---------------------------------
  44. setTimeout(()=>{
  45. //AD清除广告
  46. if(document.querySelector("#HMRichBox")){
  47. document.querySelector("#HMRichBox").remove();
  48. }
  49. if(document.querySelector("#HMcoupletDivright")){
  50. document.querySelector("#HMcoupletDivright").remove();
  51. }
  52. if(document.querySelector("#HMcoupletDivleft")){
  53. document.querySelector("#HMcoupletDivleft").remove();
  54. }
  55. },"500");
  56.  
  57.  
  58. //------------------------------------C1-----------------------------------------------------------------------------
  59. if(document.querySelector("#player")){
  60. //主站外部框架
  61. console.log("1.哈哩哈哩播放器页面进入");
  62.  
  63. let style = document.createElement("style");
  64. style.type = "text/css";
  65. let str = ``;
  66. //样式收缩
  67. if(true){
  68. str = `
  69. .MyFullscreen {
  70. position:fixed;
  71. top:0px;
  72. left:0px;
  73. z-index:9999;
  74. width:100%;
  75. height:100%;
  76. }
  77. .PlayerSettings{
  78. position:fixed;
  79. left:0;
  80. z-index:999999;
  81. top:50vh;
  82. transform: translate(0,-50%);
  83. background:rgba(0,0,0,0.8);
  84. width:72px;
  85. min-width:58px;
  86. min-height:240px;
  87. float:left;
  88. padding:14px;
  89. border-radius:10px;
  90. margin:2px;
  91. transition: all 0.2s;
  92. }
  93. .PlayerSettings>*{
  94. min-width:70px;
  95. min-height:30px;
  96. float:left;
  97. }
  98. .PlayerSettings>*+*{
  99. margin-left:0px;
  100. }
  101. .EditView{
  102. text-align:center;
  103. width:60px;
  104. }
  105. .Hide{
  106. opacity:0;
  107. }
  108. `;
  109. }
  110.  
  111. style.innerHTML = str.split("\n").map(o => o.trim()).filter(o => o).join("");
  112. //console.log(style.innerHTML);
  113. document.head.appendChild(style);
  114.  
  115. let layout = document.createElement("div");
  116. layout.className = "PlayerSettings";
  117. layout.classList.add("PlayerSettings", "Hide");
  118. document.body.appendChild(layout);
  119. layout.onmouseover = function () {
  120. layout.classList.remove("Hide");
  121. };
  122. layout.onmouseout = function () {
  123. layout.classList.add("Hide");
  124. };
  125. //上一集下一集
  126. let episodes = (add) => {
  127. localStorage.ifNextFullscreen = 1;
  128.  
  129. let url = location.href;
  130. let index = url.substring(url.lastIndexOf("/") + 1, url.lastIndexOf("."));
  131. index = Number.parseInt(index) + add;
  132. url = url.substring(0, url.lastIndexOf("/") + 1) + index + url.substring(url.lastIndexOf("."));
  133. location.href = url;
  134. }
  135. //全屏按钮
  136. let fullscreens = () =>{
  137. localStorage.removeItem("ifNextFullscreen");
  138.  
  139. let player = document.getElementById("player");
  140. player.classList.toggle("MyFullscreen", !player.classList.contains("MyFullscreen"));
  141. }
  142. //切换视频源
  143. let nextResVideo = () =>{
  144. GM_setValue("C1-C2.VideoResNext", URL.createObjectURL(new Blob()));//C1-C2.VideoResNext
  145. }
  146. //跳进度
  147. let progressVideo = (timme) =>{
  148. GM_setValue("C1-C3.VdoProgressSet", -1);//C1-C3.VdoProgressSet
  149. GM_setValue("C1-C3.VdoProgressSet", timme);//C1-C3.VdoProgressSet
  150. }
  151.  
  152.  
  153. //按钮界面收缩
  154. if(true){
  155. let items = [
  156. {
  157. label: "全屏",
  158. click: () => {
  159. fullscreens();
  160. }
  161. },
  162. {
  163. label: "上一集",
  164. click: () => {
  165. episodes(-1);
  166. }
  167. },
  168. {
  169. label: "下一集",
  170. click: () => {
  171. episodes(1);
  172. }
  173. },
  174. {
  175. label:"换源",
  176. click:() => {
  177. nextResVideo();
  178. }
  179. },
  180. {
  181. label:"progress"
  182. },
  183. {
  184. label:"跳片头",
  185. click:()=>{
  186. let et = document.querySelector("#et_time").value;
  187. let saveTime = (GM_getValue('headTime')) ? GM_getValue('headTime') : 90;
  188. if(et != saveTime){
  189. GM_setValue('headTime', et);
  190. }
  191.  
  192. let etL = document.querySelector("#et_time2").value;
  193. let save2Time = (GM_getValue('tailTime')) ? GM_getValue('tailTime') : 360;
  194. if(etL != save2Time){
  195. GM_setValue('tailTime', etL);
  196. }
  197.  
  198. progressVideo(et);
  199. }
  200. },
  201. {
  202. label:"checkInput",
  203. click:()=>{
  204. //全自动按键触发
  205. let all = document.querySelector("#ck_allAuto");
  206. if(all.checked){
  207. GM_setValue('allAuto3', 1);
  208. }else{
  209. GM_deleteValue('allAuto3');
  210. }
  211. }
  212. }
  213. ]
  214.  
  215. items.forEach(item => {
  216. //进度栏
  217. if(item.label == "progress"){
  218. let dv = document.createElement("div");
  219. dv.appendChild(document.createTextNode('头 '));
  220. let el1Et = document.createElement("input");
  221. el1Et.style.width = "49px";
  222. el1Et.className = "EditView";
  223. el1Et.id = "et_time";
  224. el1Et.value = (GM_getValue('headTime')) ? GM_getValue('headTime'):90;
  225. dv.appendChild(el1Et);
  226. dv.appendChild(document.createTextNode('尾 '));
  227. let el2Et = document.createElement("input");
  228. el2Et.style.width = "49px";
  229. el2Et.className = "EditView";
  230. el2Et.id = "et_time2";
  231. el2Et.value = (GM_getValue('tailTime')) ? GM_getValue('tailTime'):360;
  232. dv.appendChild(el2Et);
  233. layout.appendChild(dv);
  234. }
  235. //自动触发
  236. else if(item.label == "checkInput"){
  237. let dv = document.createElement("div");
  238. let elCk = document.createElement("input");
  239. elCk.id = "ck_allAuto";//全自动
  240. elCk.type = "checkbox";
  241. elCk.checked = (GM_getValue('allAuto3'));
  242. elCk.addEventListener("click", item.click);
  243. dv.appendChild(elCk);
  244. dv.appendChild(document.createTextNode(' 全自动'));
  245. layout.appendChild(dv);
  246. }
  247. //按钮
  248. else{
  249. let el = document.createElement("button");
  250. el.innerText = item.label;
  251. el.addEventListener("click", item.click);
  252. layout.appendChild(el);
  253. }
  254. })
  255. }
  256.  
  257. //下一集触发自动全屏
  258. if(localStorage.ifNextFullscreen == 1){
  259. fullscreens();
  260. }
  261.  
  262. //自动切换下一集
  263. GM_addValueChangeListener("C3-C1.NextVideo", (name, oldValue, newValue, remote)=>{
  264. episodes(1);
  265. });
  266.  
  267.  
  268.  
  269.  
  270. return;
  271. }
  272. //End---------------------------------C1-----------------------------------------------------------------------------
  273.  
  274. }
  275. else{;
  276. if(document.querySelector("#divplay")){
  277. //----------------------------------------------C2---------------------------------------------------------------
  278. document.querySelector("#playiframe").style.height = "100%";
  279. //二级播放器容器中间件
  280. console.log("2.播放器中间件");
  281.  
  282. //视频源列表
  283. let playroad = document.querySelector("#playroad");
  284. if(playroad){
  285. playroad.style.position = "absolute";
  286. playroad.style.left = "0px";
  287. playroad.style.top = "0px";
  288. playroad.style.width = "100%";
  289. playroad.style.opacity = "0";
  290. playroad.onmouseover = function () {
  291. this.style.opacity = "1";
  292. };
  293. playroad.onmouseout = function () {
  294. this.style.opacity = "0";
  295. };
  296. }else{
  297. return;
  298. }
  299.  
  300. //切换视频源
  301. GM_addValueChangeListener("C1-C2.VideoResNext", (name, oldValue, newValue, remote)=>{
  302. console.log("换源按钮触发");
  303. let resLists = document.getElementById("playroad");
  304. //优先备用线2(判断是否优先使用)
  305. let beiTag = false;
  306. let useBei = true;//暂时先true
  307. if(useBei){
  308. resLists.childNodes.forEach(item => {
  309. if(item.innerText == "备用线2" && item.style.color != "rgb(47, 179, 255)"){//未选中
  310. item.click();
  311. beiTag = true;
  312. }
  313. });
  314. if(beiTag){
  315. return;
  316. }
  317. }
  318. //下一个源
  319. resLists.childNodes.forEach(item => {
  320. if(item.tagName == 'A'){
  321. if(item.style.color == "rgb(47, 179, 255)"){//选中 蓝色
  322. beiTag = true;
  323. }else if(item.style.color == "rgb(170, 170, 170)" && beiTag){//灰色
  324. beiTag = false;
  325. item.click();
  326. }else if(item.style.color == "rgb(255, 0, 0)" && beiTag){//红色
  327. beiTag = false;
  328. item.click();
  329. }
  330. }
  331. });
  332. });
  333.  
  334. //自动播放
  335. setTimeout(()=>{
  336. if(GM_getValue('allAuto3')){
  337. GM_setValue("C1-C3.VdoProgressSet", -1);
  338. GM_setValue("C1-C3.VdoProgressSet", (GM_getValue('headTime')) ? GM_getValue('headTime') : 90);
  339. }else{
  340. GM_setValue("C2-C3.AutoPlay", URL.createObjectURL(new Blob()));
  341. }
  342.  
  343. },"1000");
  344.  
  345. return;
  346. //End-------------------------------------------C2---------------------------------------------------------------
  347. }
  348.  
  349. //--------------------------------------------------------------C3---------------------------------------------------
  350. //a1:线1,2 video:线3,4 player1:备线1,2,线10
  351. if(document.querySelector('#a1') || document.querySelector("#player1") || document.querySelector("#video")){
  352. //播放器内层
  353. console.log("3.播放器层");
  354.  
  355. //视频播放器监听
  356. setTimeout(()=>{
  357. //console.log("vdp set time");
  358. document.querySelector('video').addEventListener("ended", ()=>{
  359. GM_setValue("C3-C1.NextVideo", URL.createObjectURL(new Blob()));
  360. });
  361. document.querySelector('video').ontimeupdate = ()=>{
  362. if(GM_getValue('allAuto3')){//是否开启全自动
  363. let tailT = (GM_getValue('tailTime')) ? GM_getValue('tailTime') : 360;
  364. if(document.querySelector('video').currentTime > tailT){
  365. GM_setValue("C3-C1.NextVideo", URL.createObjectURL(new Blob()));
  366. }
  367. }
  368. };
  369.  
  370. },(document.querySelector('video')?"0":"8000"));//如果搜索不到,延迟搜索
  371.  
  372.  
  373. //自动播放功能
  374. let autoPlay = () =>{
  375. let vdo = document.querySelector('video');
  376. if(vdo.paused){//如果已经暂停,那么就可能静音播放
  377. vdo.muted = true;
  378. vdo.play();
  379. }
  380.  
  381. //静音后处理
  382. if(vdo.muted){
  383. //添加解除静音按钮
  384. let bd = document.querySelector('body');
  385. let btnSound = document.querySelector('#soundBtn');
  386. if(!btnSound){
  387. let el = document.createElement("button");
  388. el.id = "soundBtn";
  389. el.style.position = "absolute";
  390. el.style.width = "100%";
  391. el.style.height = "100%";
  392. el.style.bottom = "0px";
  393. el.style.top = "0px";
  394. el.style.left = "0px";
  395. el.style.right = "0px";
  396. el.style.color = "rgb(255,255,255)";
  397. el.style.background = "rgba(0,0,0,0.5)";
  398. el.innerText = "音量点击";
  399. el.addEventListener("click", ()=>{
  400. document.querySelector('#soundBtn').remove();
  401. document.querySelector('video').muted = false;
  402. });
  403. bd.appendChild(el);
  404. }
  405. }
  406. }
  407.  
  408. //视频快进
  409. GM_addValueChangeListener("C1-C3.VdoProgressSet", (name, oldValue, newValue, remote)=>{
  410. //快进
  411. let vdo = document.querySelector('video');
  412. if(oldValue == "-1" && vdo){
  413. vdo.currentTime += +newValue;
  414. autoPlay();
  415. }
  416. });
  417.  
  418. //自动播放
  419. GM_addValueChangeListener("C2-C3.AutoPlay", (name, oldValue, newValue, remote)=>{
  420. if(document.querySelector('video')){
  421. autoPlay();
  422. }
  423. });
  424.  
  425. return;
  426. }
  427. //--------------------------------------------------------------C3---------------------------------------------------
  428.  
  429. console.log("4.其他:" + url);
  430. }
  431. })();

QingJ © 2025

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