Greasy Fork is available in English.
自动将所有蓝奏云链接重定向至lanzn.com。自动记住并填写蓝奏云密码。
当前为
// ==UserScript==
// @name 蓝奏云重定向+记住密码
// @namespace http://greasyfork.icu/zh-CN/scripts?set=589091
// @version 1.0
// @description 自动将所有蓝奏云链接重定向至lanzn.com。自动记住并填写蓝奏云密码。
// @author 呆呆
// @exclude https://developer-oss.lanzou*.com/file/*
// @match https://*lanzou*.com/*
// @match https://*lanzn.com/*
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_listValues
// @grant GM_deleteValue
// @grant GM_notification
// ==/UserScript==
function Toast(text) {
if(typeof(window.via)=="object") window.via.toast(text)
else GM_notification(text);
}
// 获取当前网页链接
var currentUrl = window.location.href;
// 检查当前网址是否为 https://lanzout.com/
if (!currentUrl.startsWith('https://www.lanzn.com/')) {
// 替换域名为 "lanzout.com"
var newUrl = currentUrl.replace(window.location.hostname, 'www.lanzn.com');
Toast("重定向中....");
// 重新访问新链接
window.location.href = newUrl;
}
// 获取文本框元素
const inputElement = document.getElementById('pwd');
// 获取按钮元素
const subButton = document.getElementById('sub');
const passwddivButton = document.querySelector('.passwddiv-btn');
// 获取存储的值
const storedCredentials = GM_getValue(currentUrl);
// 检查是否存在存储的值
if (storedCredentials) {
// 如果有存储的数据,将其填充到文本框中
inputElement.value = storedCredentials.password;
// 检查是否存在.passwddiv-btn元素
if (passwddivButton) {
// 如果存在,点击.passwddiv-btn
passwddivButton.click();
} else {
// 否则点击sub
subButton.click();
}
}
// 监听文本框的输入事件
inputElement.addEventListener('input', function() {
// 获取当前网页标题
const pageTitle = document.title;
// 将标题和密码存储为对象
const credentials = {
title: pageTitle,
password: inputElement.value
};
// 将对象存储在GM存储中
GM_setValue(currentUrl, credentials);
});
// 使用GM_registerMenuCommand添加管理密码的菜单命令
GM_registerMenuCommand('查看密码', function() {
// 获取所有存储的键
const allKeys = GM_listValues();
// 存储所有存储的数据
const allStoredData = {};
// 遍历所有键,并获取对应的值
allKeys.forEach(key => {
const value = GM_getValue(key);
allStoredData[key] = value;
});
if (Object.keys(allStoredData).length > 0) {
// 构建展示消息
let message = '';
Object.entries(allStoredData).forEach(([key, value]) => {
message += `${value.title} (${key}):${value.password}\n---\n`;
});
// 显示消息
alert(message);
} else {
Toast('没有存储的密码!');
}
});
// 使用GM_registerMenuCommand添加管理密码的菜单命令
GM_registerMenuCommand('🔒管理密码', function() {
// 获取所有存储的键值对
const allStoredData = {};
const allKeys = GM_listValues();
allKeys.forEach(key => {
const value = GM_getValue(key);
allStoredData[key] = value;
});
// 构建展示消息
let message = '';
Object.entries(allStoredData).forEach(([key, value]) => {
message += `${value.title} (${key}):${value.password}\n`;
});
// 提示用户编辑密码列表
const editedList = prompt('请编辑网址和密码列表', message);
if (editedList !== null) {
// 清空所有存储的密码
allKeys.forEach(key => {
GM_deleteValue(key);
});
// 将编辑后的列表转换为标准格式并存储
const editedLines = editedList.split('\n');
editedLines.forEach(line => {
const [url, password] = line.split(':');
if (url && password) {
const [urlValue, title] = url.split(' (');
GM_setValue(urlValue.trim(), { title: title.slice(0, -1), password: password.trim() });
}
});
Toast('密码列表已更新!');
}
});