Greasy Fork is available in English.
自动将所有蓝奏云链接重定向至lanzn.com。自动记住并填写蓝奏云密码。
当前为
// ==UserScript==
// @name 蓝奏云重定向+记住密码
// @namespace http://greasyfork.icu/zh-CN/scripts?set=589091
// @version 0.9
// @description 自动将所有蓝奏云链接重定向至lanzn.com。自动记住并填写蓝奏云密码。
// @author 呆呆
// @exclude https://developer-oss.lanzou*.com/file/*
// @match https://*lanzou*.com/*
// @match https://*lanzn.com/*
// @grant GM_registerMenuCommand
// @grant none
// ==/UserScript==
// 获取当前网页链接
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');
// 重新访问新链接
window.location.href = newUrl;
}
// 获取文本框元素
const inputElement = document.getElementById('pwd');
// 获取按钮元素
const subButton = document.getElementById('sub');
const passwddivButton = document.querySelector('.passwddiv-btn');
// 检查localStorage中是否已经存储了该网址的数据
if (localStorage.getItem(window.location.href)) {
// 如果有存储的数据,将其填充到文本框中
inputElement.value = localStorage.getItem(window.location.href);
// 检查是否存在.passwddiv-btn元素
if (passwddivButton) {
// 如果存在,点击.passwddiv-btn
passwddivButton.click();
} else {
// 否则点击sub
subButton.click();
}
}
// 监听文本框的输入事件
inputElement.addEventListener('input', function() {
// 当文本框内容发生变化时,将其保存到localStorage中
localStorage.setItem(window.location.href, inputElement.value);
});
// 使用GM_registerMenuCommand添加管理密码的菜单命令
GM_registerMenuCommand('🔒管理密码', function() {
// 检查是否已经存储了密码
const storedPassword = localStorage.getItem(window.location.href);
if (storedPassword) {
// 提示用户是否删除已存储的密码
const deleteStoredPassword = confirm('是否删除已存储的密码?\n---\n'+storedPassword);
if (deleteStoredPassword) {
// 删除本地存储的密码
localStorage.removeItem(window.location.href);
confirm('密码已删除!');
}
} else {
confirm('当前没有存储的密码!');
}
});