Downloads all messages (including private) in current chat
当前为
// ==UserScript==
// @name ChatLog
// @namespace http://alphaoverall.com
// @version 0.5
// @description Downloads all messages (including private) in current chat
// @author AlphaOverall
// @include *://www.kongregate.com/games/*/*
// ==/UserScript==
// Check for holodeck to load
function check() {
if (!holodeck) { setTimeout(check, 1000);}
else {
console.log("[ChatLog]: Holodeck loaded");
start();
}
} check();
// Main function
function start() {
holodeck.addChatCommand("chatlog", function(l, msg){
let z = msg.match(/^\/\S+\s+(.+)/), type = ".txt";
// Allow an optional html download
if (z && z[1] == "html") type = ".html";
// Get active chat message window and log
let element = jQuery(".chat_room_template:visible .chat_message_window")[0];
let log = (type === ".html" ? element.innerHTML : element.innerText);
// Create link to download document
var download = document.createElement("a");
download.href = "data:attachment/text," + encodeURI(log);
download.target = "_blank";
// Set a unique name
download.download = "Log_" + (new Date().toLocaleString()) + type;
// Download it
download.click();
// Don't send command to chat window
return false;
});
// Add /log as an optional form of command
holodeck._chat_commands.log = holodeck._chat_commands.chatlog;
}