最终版本,你看还能简化不?
// ==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
// ==/UserScript==
function doLogin() {
var loginButton, id;
if (window.location.pathname == "/") {
loginButton = document.getElementById("b_login");
id = document.getElementById("id");
} else {
loginButton = document.getElementById("u_login_submit");
id = document.getElementById("u_login_id");
}
if (loginButton) {
if (id && id.value.length) {
loginButton.click();
}
}
}
var timeoutID;
function tm_doLogin() {
timeoutID = setTimeout(doLogin,1000);
}
window.addEventListener("load", tm_doLogin, false);
【 在 doggeddog 的大作中提到: 】
: chrome 试了吗, 应该会有问题
:
--
FROM 171.221.52.*