蓝奏云重定向+记住密码

自动将所有蓝奏云链接重定向至lanzn.com。自动记住并填写蓝奏云密码。

目前为 2024-03-03 提交的版本。查看 最新版本

// ==UserScript==
// @name         蓝奏云重定向+记住密码
// @namespace   https://gf.qytechs.cn/zh-CN/scripts?set=589091
// @version      0.9
// @description  自动将所有蓝奏云链接重定向至lanzn.com。自动记住并填写蓝奏云密码。
// @author       You
// @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');

    if(typeof(window.via)=="object") window.via.toast("重定向中....");
    else GM_notification("重定向中....");

    // 重新访问新链接
    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);
    if(typeof(window.via)=="object") window.via.toast('密码已删除!');
    else GM_notification('密码已删除!');
    }
  } else {
   if(typeof(window.via)=="object") window.via.toast('当前没有存储的密码!');
   else GM_notification('当前没有存储的密码!');
  }
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址