// ==UserScript==
// @name Digit77 Helper
// @namespace cn.XYZliang.digit77Helper
// @version 2.4.6
// @description 自动复制提取码,跳过ouo.io的三秒等待时间!
// @require https://code.jquery.com/jquery-3.7.1.min.js
// @license GNU General Public License v3.0
// @author XYZliang
// @homepage https://greasyfork.org/zh-CN/scripts/495107-digit77-helper
// @match *://www.digit77.com/*
// @match *://ouo.io/*
// @match *://ouo.press/*
// @match *://cloaking.link/*
// @match *://*.sharepoint.com/*
// @match *://www.aliyundrive.com/*
// @match *://pan.quark.cn/*
// @icon https://www.digit77.com/_nuxt/logo-s.BqVYlxIi.png
// @grant unsafeWindow
// @grant GM_setClipboard
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_listValues
// @grant GM_xmlhttpRequest
// @grant GM_notification
// @grant GM_getClipboard
// @run-at document-end
// @connect *
// @downloadURL https://update.greasyfork.icu/scripts/495107/Digit77%20Helper.user.js
// @updateURL https://update.greasyfork.icu/scripts/495107/Digit77%20Helper.meta.js
// ==/UserScript==
/* globals jQuery, $ */
'use strict';
// 用户设置
let settings = GM_getValue('settings', {
autofill: true,
ouo: true,
cloaking: true,
quark: true,
baidu: true,
onedrive: true,
aliyun: true,
error: true,
});
// Clean up
cleanupStorage();
let url = location.host;
// Main logic goes here ---------------------------------------------------------
if (url.includes('digit77.com')) {
handleDigit77();
} else if (url.includes('ouo')) {
handleOuo();
} else if (url.includes('cloaking')) {
handleCloaking();
} else if (url.includes('pan.quark.cn')) {
hanndleQuark();
} else if (url.includes('sharepoint.com')) {
if (settings.onedrive)
doFillAction('#txtPassword', '#btnSubmitPassword', 'digit77');
} else {
console.log('Unknown url! (' + url + ')');
return;
}
// Function definitions ---------------------------------------------------------
function handleCloakingGo(pw) {
GM_xmlhttpRequest({
method: 'POST',
url: `${location.origin}/links/go`,
data: $('#go-link').serialize(),
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
},
onload: function (response) {
console.log('Onload response:', response.responseText);
if (response.status === 200) {
try {
var data = JSON.parse(response.responseText);
if (data.status !== 'error') {
let realLink = data.url;
let finalUrlWithPwd = addGetParameter(
realLink,
'Digit77HelperPwd',
//GM_getValue(pw),
getPasscode(pw),
);
setTimeout(() => {
window.location.href = finalUrlWithPwd;
}, 1000);
} else {
console.error('Error from server:', data);
}
} catch (e) {
console.error('Failed to parse response:', e);
}
} else {
console.error('Failed to get the real link', response.status);
}
},
onerror: function (response) {
console.error(
'Request failed:',
response.status,
response.statusText,
);
},
});
}
// Function definitions ---------------------------------------------------------
function handleCloaking() {
if (!settings.cloaking) return;
console.group(`[Digital77 Helper] -- ${location.origin}`);
consoleLog('正在跳过Cloaking');
// Directly set text using .text() for better consistency and compatibility.
$('h1').text('Digit77 Helper正在跳过等待!');
$('#form-continue > button').text('欢迎使用Digit77 Helper');
let pathSegments = location.pathname.split('/')[1];
if (settings.error) consoleLog('path segments: ' + pathSegments);
// set cloaking status to 0 for the first time
GM_setValue('cloaking', 0);
// if the cloaking status is 0, then set the cloaking status to 1
if (GM_getValue('cloaking') === 0) {
GM_setValue('cloaking', 1);
// click the continue button
$('#form-continue > button').click();
//request url from cloaking is https://cloaking.link/links/go
setTimeout(() => {
handleCloakingGo(pathSegments);
}, 1000);
}
// if find element body > div.container > div > div > div > div:nth-child(5) > a, then extract the link form it
if (
$('body > div.container > div > div > div > div:nth-child(5) > a')
.length > 0
) {
WaitForLink();
}
console.groupEnd();
}
function WaitForLink() {
// focuse on the link
$(
'body > div.container > div > div > div > section.link-tab-body.mb-5 > div > div > div:nth-child(2) > div > fieldset > div > div.col-md-3.g-link-body > div > div > a',
).focus();
// wait for 5 seconds to get the link
setTimeout(() => {
let link = $(
'body > div.container > div > div > div > section.link-tab-body.mb-5 > div > div > div:nth-child(2) > div > fieldset > div > div.col-md-3.g-link-body > div > div > a',
).attr('href');
if (link.includes('javascript')) WaitForLink();
let pw = location.pathname.split('/')[1];
let passcode = getPasscode(pw)
if (settings.error)
consoleLog('Cloaking link: ' + pw + ' pwd: ' + passcode);
let finalUrl = addGetParameter(
link,
'Digit77HelperPwd',
//GM_getValue(pw),
passcode,
);
window.location.href = finalUrl;
}, 2800);
}
function hanndleQuark() {
if (!settings.quark) return;
// get the password from parameter
const urlObj = new URL(window.location.href);
// if the url contains the parameter Digit77HelperPwd, then fill the password
if (!urlObj.search.includes('Digit77HelperPwd')) {
return;
}
const queryParams = new URLSearchParams(urlObj.search);
const digit77HelperPwd = queryParams.get('Digit77HelperPwd');
if (settings.error) {
console.log('Debugging <夸克网盘>: ');
console.log('href: ', window.location.href);
console.log('code: ', digit77HelperPwd);
}
if (digit77HelperPwd !== undefined) {
doFillAction(
'#ice-container > div.ShareReceivePC--wrapcontainer--3OAJUiU.share-container-cls-name-for-get-dom > div.ShareReceivePC--wrapcontent--2fA9pbO > div > div.ShareReceivePC--content--3zjCAuj > div.ShareReceivePC--input-wrap--2FUw27N > input',
'#ice-container > div.ShareReceivePC--wrapcontainer--3OAJUiU.share-container-cls-name-for-get-dom > div.ShareReceivePC--wrapcontent--2fA9pbO > div > div.ShareReceivePC--content--3zjCAuj > div:nth-child(5) > button',
digit77HelperPwd,
);
} else alert('请手动粘贴提取码:', GM_getClipboard());
}
function handleOuo() {
if (!settings.ouo) return;
console.group(`[Digital77 Helper] -- ${location.href}`);
consoleLog('正在跳过ouo');
// Use .ready() to ensure the DOM is fully loaded before attempting to modify elements.
$(document).ready(function () {
// Directly set text using .text() for better consistency and compatibility.
$('h4').text('Digit77 Helper正在跳过等待!');
$('.btn-main').text('欢迎使用Digit77 Helper');
let pathSegments = location.pathname.split('/');
let passcode = getPasscode(pathSegments[2]);
if (settings.error)
consoleLog(
'path segments: ' +
pathSegments +
' pwd key: ' +
pathSegments[2] +
' pwd: ' +
//GM_getValue(pathSegments[2]),
passcode,
);
// Check if the path contains 'go' and proceed with the specific logic for those pages.
if (pathSegments[1] === 'go') {
let reallyUrlGetter = `${location.origin}/xreallcygo/${pathSegments[2]}`;
let reallyUrlData = $('#form-go').serialize();
// Use GM_xmlhttpRequest for cross-origin requests.
GM_xmlhttpRequest({
method: 'POST',
url: reallyUrlGetter,
data: reallyUrlData,
headers: {
'Content-Type':
'application/x-www-form-urlencoded;charset=UTF-8',
},
onload: function (response) {
// Construct the final URL with the password parameter if the request was successful.
let finalUrl = addGetParameter(
response.finalUrl,
'Digit77HelperPwd',
passcode,
);
if (response.status === 200) {
// Redirect after a slight delay to enhance ad revenue potentially.
setTimeout(
() => (window.location.href = finalUrl),
1000,
);
} else {
failedToGetJumpAddress(getPasscode(pathSegments[2]));
}
},
onerror: function () {
failedToGetJumpAddress(getPasscode(pathSegments[2]));
},
});
} else {
// For non-'go' pages, wait before clicking the main button to pass through ads.
setTimeout(() => $('.btn-main').click(), 1500);
}
});
console.groupEnd();
}
// Main logic for Digit77 ---------------------------------------------------------
function handleDigit77() {
$(document).ready(function () {
// Create settings form directly
const settingsFormHtml = `
Digit77 Helper设置