Greasy Fork

Greasy Fork is available in English.

配合“百度网盘视频播放尊享 VIP | 解锁视频倍数 | 解锁全部清晰度”(原作者为:Cangshi)使用

原脚本失效,原作者大大还未更新脚本,但原脚本在老地址可以正常运行,于是用此脚本进行暂时的维护。

当前为 2023-04-04 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         配合“百度网盘视频播放尊享 VIP | 解锁视频倍数 | 解锁全部清晰度”(原作者为:Cangshi)使用
// @namespace    http://tampermonkey.net/
// @version      0.1.2
// @description  原脚本失效,原作者大大还未更新脚本,但原脚本在老地址可以正常运行,于是用此脚本进行暂时的维护。
// @author       Yangzh12
// @include      https://pan.baidu.com/play/video*
// @include      https://pan.baidu.com/pfile/*
// @include      https://pan.baidu.com/disk/main*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=baidu.com
// @grant        none
// ==/UserScript==

var currentUrl = window.location.href;

// 替换URL中的pfile为play/video#
var newUrl = currentUrl.replace("pfile", "play/video#");

// 跳转到替换后的页面
window.location.href = newUrl;


// 创建跳转按钮元素,设置属性和样式
var button = document.createElement("button");
button.style.width = "3cm";
button.style.height = "3cm";
button.style.backgroundColor = "red";
button.style.position = "absolute";
button.style.left = "2cm";
button.style.top = "2cm";
button.innerText = "点击此跳转到超清画质,如果第一次使用本脚本,请自行点击创建组群,否则无法跳转";
// 添加点击事件
button.onclick = function() {
  // 执行代码
  document.querySelector("#video-toolbar > div.video-toolbar-buttonbox > a:nth-child(2) > span > span").click();
  setTimeout(function() {
    document.querySelector("#dialog1 > div.dialog-body > div > div.share-file-body__nav > div.share-file-body__tabs > div.share-file-body__tabs-item.is-friend").click();
    setTimeout(function() {
      document.querySelector("#dialog1 > div.dialog-body > div > div.share-file-body__content > div.share-file-body__friend > div > div.share-file__friend-body > div.share-file__friend-list-container.has-scroll > div.share-file__friend-list-wrapper.has-scroll > div.share-file__friend-list.is-group > div.share-file__friend-list-title").click()
      setTimeout(function() {
        // 选择器
const SELECTOR = '#dialog1 > div.dialog-body > div > div.share-file-body__content > div.share-file-body__friend > div > div.share-file__friend-body > div.share-file__friend-list-container.has-scroll > div.share-file__friend-list-wrapper.has-scroll > div.share-file__friend-list.is-group.is-expand > div.share-file__friend-list-body > div > div';

// 获取同级元素的集合
const siblingsCollection = document.querySelectorAll(SELECTOR);

// 创建包含数据的对象数组
const siblingsArray = Array.from(siblingsCollection).map((item) => ({
  name: item.querySelector('.share-file__friend-list-item-name').textContent,
  element: item,
}));

const container = document.createElement('div');
container.style.position = 'fixed';
container.style.top = '50%';
container.style.left = '0';
container.style.transform = 'translate(0, -50%)';
container.style.padding = '20px';
container.style.background = 'white';
container.style.zIndex = '999';
container.style.borderRadius = '5px';
container.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.3)';
document.body.appendChild(container);

// 创建一个标题
const title = document.createElement('h2');
title.textContent = '你有三秒的时间选择,否则默认第一个或上一个组群';
container.appendChild(title);

// 创建项目列表和相应的复选框
const list = document.createElement('ul');
siblingsArray.forEach(({ name }) => {
  const listItem = document.createElement('li');
  const checkbox = document.createElement('input');
  checkbox.type = 'checkbox';
  checkbox.name = name;
  listItem.appendChild(checkbox);
  listItem.appendChild(document.createTextNode(name));
  list.appendChild(listItem);
});
container.appendChild(list);



// 监听选择
const checkboxes = list.querySelectorAll('input[type="checkbox"]');
let timerId;
checkboxes.forEach((checkbox, index) => {
  checkbox.addEventListener('change', () => {
    clearTimeout(timerId); // 清除计时器
    if (checkbox.checked) {
      const selectedItem = siblingsArray.find(
        ({ name }) => checkbox.name === name
      ).element;
      selectedItem.click();

      // 保存选择到本地存储中
      localStorage.setItem('lastSelected', checkbox.name);
    }
  });
});

// 3秒内不选择自动点击获取到的第一个元素或上一次选择的元素
timerId = setTimeout(() => {
  let isAnyChecked = false;
  checkboxes.forEach(checkbox => {
    if (checkbox.checked) {
      isAnyChecked = true;
    }
  });
  if (!isAnyChecked) {
    const lastSelectedName = localStorage.getItem('lastSelected');
    const lastSelectedItem = siblingsArray.find(
      ({ name }) => name === lastSelectedName
    );
    if (lastSelectedItem) {
      lastSelectedItem.element.click();
    } else {
      const firstItem = siblingsArray[0].element;
      firstItem.click();
    }
  }
}, 3000);
        setTimeout(function() {
          document.querySelector("#dialog1 > div.dialog-body > div > div.share-file-body__content > div.share-file-body__friend > div > div.share-file__friend-actions > button > span").click()
          setTimeout(function() {
            document.querySelector("body > div.module-yun-tip > div > span.tip-msg > a").click()
          }, 1000);
        }, 5000);
      }, 500);
    }, 1000);
  }, 1000);
};

// 添加按钮元素到页面中
document.body.appendChild(button);

// 添加新的按钮元素到页面中
var currentUrl = window.location.href;
if (currentUrl == "https://pan.baidu.com/disk/main#/im/session?from=mbox") {
  // 在距离页面左上角2cm的位置添加一个长为3厘米,宽为2厘米的红色的元素按钮,按钮名字为“正在加载中,如果第一次使用本脚本,请自行点击创建组群”
  var element = document.createElement("button");
  element.style.width = "3cm";
  element.style.height = "2cm";
  element.style.backgroundColor = "red";
  element.innerHTML = "正在加载中";
  element.style.position = "absolute";
  element.style.top = "8cm";
  element.style.left = "4cm";
  document.body.appendChild(element);
}
// 定义一个检查元素是否存在的函数
function checkElement() {
var element = document.querySelector("body > div.nd-main-layout > div.nd-main-layout__wrapper > div.nd-main-layout__body > div > div.im-contain > div.im-contain__left > div > div.im-l-contain > div.im-l-contain__content > div > div > div > div:nth-child(1) > div:nth-child(2) > div > div.im-list-card__content > div > div.im-list-card__cov--top")
if (element) {
//获取需要点击的按钮元素
var button = document.getElementById("myButton");
    setTimeout(function() {
      element.click();
    }, 1000); // 如果元素出现,则延迟1秒钟后执行点击事件
    clearInterval(intervalId); // 如果元素出现,则清除定时器
  }
}

// 设置定时器每隔一段时间检查一次元素是否存在
var intervalId = setInterval(checkElement, 1000);

setTimeout(function(){
document.querySelector("body > div.nd-main-layout > div.nd-main-layout__wrapper > div.nd-main-layout__body > div > div.im-contain > div.im-contain__right > div > div > div > span > i").click()
}, 8000);

setTimeout(function(){
document.querySelector("body > div.nd-main-layout > div.nd-main-layout__wrapper > div.nd-main-layout__body > div > div.u-drawer__wrapper.is-doc > div > div > section > div.im-doclib > div.im-doc-lib > div.im-pan-list.im-pan-list-loading > div > div > div.im-pan-table__body.mouse-choose-list > table > tbody > tr:nth-child(1) > td:nth-child(2) > div > div > a").click()
}, 9000);