Greasy Fork

来自缓存

Greasy Fork is available in English.

Fuck百度云

就他妈不装百度云管家

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name            Fuck百度云
// @description     就他妈不装百度云管家
// @namespace       http://www.jycggyh.cn/
// @author          艮古永恒
// @version         1.1.0
// @include         pan.baidu.com/*
// @match           *://pan.baidu.com/*
// @grant           none
// @run-at          document-end
// @require         http://greasyfork.icu/scripts/21104-%E6%88%91%E7%9A%84js%E5%87%BD%E6%95%B0%E5%BA%93/code/%E6%88%91%E7%9A%84JS%E5%87%BD%E6%95%B0%E5%BA%93.user.js
// ==/UserScript==

function addToolbarBtn2(name, iconClass) {
  // toolbar Div
  var oToolbar = queryByCName("bar").getElementsByTagName("div")[1];
  // new btn
  var oButton = document.createElement("a");
  oButton.className = "g-button";
  oButton.href="javascript:void(0)";
  oToolbar.appendChild(oButton);
  // btn -> span
  var oBtnRoot = document.createElement("span");
  oBtnRoot.className = "g-button-right";
  oButton.appendChild(oBtnRoot);
  // btn -> span -> em
  oBtnIcon = document.createElement("em");
  oBtnIcon.className = iconClass;
  oBtnIcon.title = name;
  oBtnRoot.appendChild(oBtnIcon);
  // btn -> span -> text
  oBtnText = document.createElement("span");
  oBtnText.className = "text";
  oBtnText.innerHTML = name;
  oBtnRoot.appendChild(oBtnText);
  // set up end
  return oButton;
}

function getCurrentPath2() {
  var oUl = queryByCName("historylistmanager-history");
  var oLi = queryByTName("li", oUl)[1];
  var oSpans = oLi.getElementsByTagName("span");
  if(oSpans.length == 0) {
    return "";
  }
  var oSpan = oSpans[oSpans.length-1];
  return oSpan.title.substring(4);
}

// 初始化设置
var DownloadAPI = "https://pcs.baidu.com/rest/2.0/pcs/file?method=download&app_id=266719&path=";
var oBtnDown = addToolbarBtn2("默认操作", "icon icon-download-gray");
var DOWNLOAD = false;
var oBtnIcon;
var oBtnText;
oBtnDown.onclick = function () {
  DOWNLOAD = !DOWNLOAD;
  updateBtn();
  
  if(!DOWNLOAD) {
    window.location.reload(true);
  }
  updateFiles();
}

function updateFiles() {
  if(!DOWNLOAD) {
  	return; 
  }
  var oFiles = queryByCName("list-view").getElementsByTagName("dd");
  var CurrentPath = getCurrentPath2();
  var oFile;
  for(var i = 0; i < oFiles.length; i++) {
      oFile = oFiles[i].getElementsByClassName("file-name")[0].getElementsByClassName("text")[0].getElementsByClassName("filename")[0];
      oFile.onclick = function() {
        window.location.href = DownloadAPI + CurrentPath + "/" + this.title;
      }
  }
}

function updateBtn() {
  if(!DOWNLOAD) {
  	oBtnIcon.title = "默认操作";
    oBtnText.innerHTML = "默认操作";
  } else {
    oBtnIcon.title = "下载操作";
    oBtnText.innerHTML = "下载操作";
  }
}