非常便捷,帮你免去所有不必要的重复点击和填写密码
当前为
// ==UserScript==
// @name switch520-auto-secret
// @namespace http://tampermonkey.net/
// @version 1.2.1
// @description 非常便捷,帮你免去所有不必要的重复点击和填写密码
// @author Kane
// @match *://*.gamers520.*
// @match *://*.gamer520.*
// @match *://download.gamer520.com/*
// @match *://download.espartasr.com/*
// @match *://download.freer.blog/*
// @match *://www.freer.blog/*
// @match *://*.xxxxx528.com/*
// @match *://www.efemovies.com/*
// @match *://www.espartasr.com/*
// @match *://www.piclabo.xyz/*
// @match *://like.gamer520.com/*
// @license MIT
// @icon https://www.google.com/s2/favicons?sz=64&domain=gamer520.com
// ==/UserScript==
(function() {
'use strict';
const el_input = function() {
return document.querySelector('input#password') ||
document.querySelector(`input[type='password']`) ||
document.querySelector(`input[name='post_password']`);
}();
const el_submit = function() {
return document.querySelector(`input[type='submit']`) ||
document.querySelector(`input[name='Submit']`) ||
document.querySelector(`input[value='提交']`);
}();
document.querySelectorAll('*').forEach((node) => {
const innerText = node.innerText;
if (
innerText?.startsWith('密码保护:') &&
!innerText?.includes('上一篇') &&
!innerText?.includes('牛夫人') &&
!innerText?.includes('当前位置') &&
!innerText?.includes('此内容受密码保护') &&
!innerText?.includes('永久防迷路')
) {
// const [result] = innerText.match(/[0-9]{3,6}/) ?? [null];
const secret = innerText.replace('密码保护:' , '');
if ( secret && el_input ) {
el_input.value = secret;
el_submit.click();
}
}
});
//以下代码将百度网盘的链接+提取码融合为一个按钮,点击之后直接跳转并填充密码
(() => {
/**
* 拿到链接文本所在的P标签
* @type {HTMLElement}
*/
const containerDiv = function() {
return Array.from(document.querySelectorAll('div.entry-content.u-text-format.u-clearfix')).find(el => {
return (el.innerText?.includes?.('提取码')) && (el.innerText?.includes?.('链接:')) && (el.innerText?.includes?.('https://pan.baidu.com'));
});
}();
if ( containerDiv ) {
const [baiduLink , baiduLinkAElement] = function() {
const aElement = Array.from(containerDiv.querySelectorAll('a')).find(el => {
return (el.href?.startsWith?.('https://pan.baidu.com'));
});
return [aElement.href , aElement];
}();
const [pwdText , pwdElement] = function() {
const pwdElement = Array.from(containerDiv.querySelectorAll('*')).find(el => el?.innerText?.startsWith?.('提取码:'));
return [pwdElement?.innerText.replace('提取码: ' , '').replaceAll(' ' , '') , pwdElement];
}();
if ( !baiduLink.includes('pwd=') && pwdText ) {
const href = baiduLink + (baiduLink.includes('?') ? `&pwd=${ pwdText }` : `?pwd=${ pwdText }`);
baiduLinkAElement.href = href;
baiduLinkAElement.innerText = baiduLinkAElement.innerText.replace(baiduLink , href);
}
containerDiv.removeChild(pwdElement);
}
})();
//以下代码跳过获取下载地址的过程 , 不需要点两次立即下载
(() => {
const downloadButton = function() {
return Array.from(document.querySelectorAll('a')).find(el => {
return el.innerText === ' 立即下载';
});
}();
let interval , invokedCount , startTime ;
if(downloadButton){
downloadButton.addEventListener('click', () => {
invokedCount = 0;
startTime = Date.now();
interval = setInterval(() => {
if(invokedCount >= 40 || Date.now() - startTime > 5 * 1000){
clearInterval(interval);
interval = null;
invokedCount = 0;
}else {
invokedCount++;
const secondDownloadButton = function() {
return Array.from(document.querySelectorAll('*')).find(el => el.innerText === '立即下载');
}();
if(secondDownloadButton){
secondDownloadButton.click();
}
}
} , 100);
})
}
})();
})();