ChatLog

Downloads all messages (including private) in current chat

当前为 2015-08-17 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         ChatLog
// @namespace    http://alphaoverall.com
// @version      0.1
// @description  Downloads all messages (including private) in current chat
// @author       AlphaOverall
// @include      http://www.kongregate.com/games/*/*
// ==/UserScript==
function check() {
    if (!holodeck) { setTimeout(check, 1000);}
    else {
        console.log("[ChatLog]: Holodeck loaded"); 
        start();
    }
} check();
function start() {
    holodeck.addChatCommand("chatlog", function(l,n){
        var z = n.match(/^\/\S+\s+(.+)/);
        var type = ".txt";
        var index = 2; // 2=Room tab, 1=Game tab, 0=empty
        //Determine which tab is active: room or game
        if (document.getElementById("game_room_tab").className != "chat_room_tab") { index = 1;}
        //Allow an optional html download
        if (z) {
            if (z[1] == "html") {type = ".html";}
        }
        //Get chat window
        var element = document.getElementsByClassName("chat_message_window")[index];
        var log = "";
        if (type == ".html")
            log = element.innerHTML;
        else
            log = element.innerText;
        var download = document.createElement("a");
        download.href = "data:attachment/text," + encodeURI(log);
        download.target = "_blank";
        var now = new Date();
        download.download = "Log_" + now.toLocaleString() + type;
        download.click();
        console.log(log);
        return false;
    });
    holodeck._chat_commands.log = holodeck._chat_commands.chatlog; //Add /log as an optional form of command
}