muyuge.bookmark.close

Close window automatically after adding a bookmark - delay 3 seconds

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        muyuge.bookmark.close
// @namespace   clumsyman
// @description Close window automatically after adding a bookmark - delay 3 seconds
// @include     http://muyuge.com/addbookcase.php?*
// @include     http://muyuge.net/addbookcase.php?*
// @include     http://www.muyuge.net/addbookcase.php?*
// @version     2
// ==/UserScript==

var delay = 3;

function closeAfter(delay, msgBox) {
    if (delay > 0) {
        msgBox.innerHTML = "窗口将在"+delay+"秒后自动关闭……";
        setTimeout(closeAfter, 1000, delay-1, msgBox);
    } else {
        window.close();
    }
}

var msgBox = document.querySelector(".msgBox > ol");
if (msgBox) {
    closeAfter(delay, msgBox);
} else {
    alert("not found: .msgBox");
}