有谱么跳过试听时间 油猴脚本

发布时间 2023-04-17 20:42:37作者: xXinG9199

须知:


? 如失效欢迎请反馈哈!

效果

脚本

// ==UserScript==
// @name         有谱么脚本
// @version      0.2
// @description  有谱么跳过试听六线谱时间、取消默认节拍器
// @author       xxing9199
// @match        https://yopu.co/view/*
// @grant        none

// ==/UserScript==

// "use strict";
window.PB_Elem;
window.PB_STATE = false;

window.PB = function () {
  let _t;

  window.get_PB_Elem();
  window.PB_Elem.click();

  if (window.PB_STATE == false) {
    _t = setInterval(() => {
      window.PB_Elem.click();
      window.PB_Elem.click();
    }, 14000);
    document.querySelector("#btn111").innerHTML = '暂停';
  } else {
    clearInterval(_t);
    document.querySelector("#btn111").innerHTML = '播放';
  }

  window.PB_STATE = !window.PB_STATE;
}

/** 获取播放按钮元素。现有两个版本,一个六线谱的,一个普通的 */
window.get_PB_Elem = function () {
  if (document.querySelector("#c > div.no-print > div.layout.svelte-dbj6vu > div.main.svelte-dbj6vu > div.player-panel.svelte-ekhves > div.right-buttons.svelte-ekhves > button") != null) {
    window.PB_Elem = document.querySelector("#c > div.no-print > div.layout.svelte-dbj6vu > div.main.svelte-dbj6vu > div.player-panel.svelte-ekhves > div.right-buttons.svelte-ekhves > button");
  } else {
    window.PB_Elem = document.querySelector("#c > div.no-print > div.layout.svelte-dbj6vu.nier > div.main.svelte-dbj6vu > div.player-panel.svelte-8wqidh > div.right-buttons.svelte-8wqidh > button");
  }
}

/** 添加界面 */
let xxing_pym_conn = document.querySelector("div.button-container");
let xxing_pym_hint = `<p style="text-align: center;">? 如失效欢迎请反馈哈! <a style="text-decoration: none;
color: #d63031;" href = '#'>?Go</a></p>`
let xxing_pym_pb = "<button id='btn111' size='big' theme='primary' type='button' class='svelte-14csrjh block' style='margin-top: 10px' onclick='PB()'></i>播放</button>";

xxing_pym_conn.innerHTML += xxing_pym_hint;
xxing_pym_conn.innerHTML += xxing_pym_pb;