自动填写提取码
// ==UserScript==
// @name 123盘自动填写提取码
// @namespace http://www.123pan.com
// @version 1.17
// @description 自动填写提取码
// @match https://www.123pan.com/*
// @match https://www.123pan.cn/*
// @match https://www.123912.com/*
// @match https://www.123865.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
if (window.location.hostname !== 'www.123pan.com') {
const newUrl = window.location.href.replace(window.location.hostname, 'www.123pan.com');
window.location.href = newUrl;
}
let currentUrl = decodeURIComponent(window.location.href);
let regex1 = /https:\/\/www\.123(pan|912)\.co(m|n)\/s\/[0-9a-zA-Z]+-[0-9a-zA-Z]+(\.html)?/;
if (!currentUrl.includes('pwd=')) {
if (regex1.test(currentUrl)) {
let str1 = regex1.exec(currentUrl)[0];
currentUrl = currentUrl.replace(str1, '');
let regex2 = /[0-9a-zA-Z]{4}/g;
let match = regex2.exec(currentUrl);
if (!match) return;
let str2 = match[0];
let newLink = str1 + '?pwd=' + str2;
window.location.href = newLink;
}
} else {
let pwd = new URLSearchParams(window.location.search).get("pwd");
let shareKey = window.location.pathname.match(/\w+-\w+/)[0];
localStorage.setItem("shareKey", shareKey);
localStorage.setItem("SharePwd", pwd);
const element = document.querySelector(".appBottomBtn");
if (!element) window.location.reload();
}
})();