GM_setValue('passwd', params.get("passwd"));diff -u a.txt b.txt
--- a.txt 2021-11-12 15:46:52.000000000 +0800
+++ b.txt 2021-11-12 15:47:10.000000000 +0800
@@ -27,9 +27,8 @@
return
}
let params = new URLSearchParams(arg[0]);
- if(params.get("id") && params.get("passwd")) {
+ if(params.get("id")) {
GM_setValue('id', params.get("id"));
- GM_setValue('passwd', params.get("passwd"));
}
}, false);
@@ -53,9 +52,7 @@
var idSave = GM_getValue('id');
var passSave = GM_getValue('passwd');
- if (idSave && passSave) {
- id.value = idSave;
- passwd.value = passSave;
+ if (idSave && id.value == idSave) {
loginButton.click();
}
}// ==UserScript==
// @name 水木自动登录
// @namespace https://github.com/doggeddog
// @homepage https://github.com/doggeddog/smth_scripts
// @version 0.6.1
// @description 水木社区不能保存登录状态, 这个脚本可以用来自动登录.
// @author doggeddog
// @match *://*.newsmth.net/*
// @match *://*.mysmth.net/*
// @run-at document-end
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
function doLogin() {
var loginButton, id, passwd;
if (window.location.pathname == "/") {
loginButton = document.getElementById("b_login");
id = document.getElementById("id");
passwd = document.getElementById("pwd");
} else {
loginButton = document.getElementById("u_login_submit");
id = document.getElementById("u_login_id");
passwd = document.getElementById("u_login_passwd");
}
if (loginButton) {
var idSave = GM_getValue('autologin_id');
if (idSave && id.value == idSave) {
loginButton.click();
}
}
}
var timeoutID;
function tm_doLogin() {
timeoutID = setTimeout(doLogin,500);
}
window.addEventListener("load", tm_doLogin, false);
window.addEventListener("hashchange", tm_doLogin, false);// ==UserScript==
// @name 水木自动登录
// @namespace https://github.com/doggeddog
// @homepage https://github.com/doggeddog/smth_scripts
// @version 0.6.1
// @description 水木社区不能保存登录状态, 这个脚本可以用来自动登录.
// @author doggeddog
// @match *://*.newsmth.net/*
// @match *://*.mysmth.net/*
// @run-at document-end
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
function doLogin() {
var loginButton, id, passwd;
if (window.location.pathname == "/") {
loginButton = document.getElementById("b_login");
id = document.getElementById("id");
passwd = document.getElementById("pwd");
} else {
loginButton = document.getElementById("u_login_submit");
id = document.getElementById("u_login_id");
passwd = document.getElementById("u_login_passwd");
}
var idSave = GM_getValue('autologin_id');
if (!idSave && id && id.value.length) {
GM_setValue('autologin_id', id.value)
idSave = id.value
}
if (loginButton) {
if (idSave && id.value == idSave) {
loginButton.click();
}
}
}
var timeoutID;
function tm_doLogin() {
timeoutID = setTimeout(doLogin,1000);
}
window.addEventListener("load", tm_doLogin, false);