您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Script created for adding the ability to save clan chat to an html file
当前为
// ==UserScript== // @name ClanChatSaver // @namespace http://tampermonkey.net/ // @version 0.9.1 // @description Script created for adding the ability to save clan chat to an html file // @author JustinR17 // @match https://www.warzone.com/MultiPlayer?ChatRoom=* // @grant none // @require http://cdn.jsdelivr.net/g/filesaver.js // @require // ==/UserScript== function saveFile(value, name) { var fileBlob = new Blob([value], { type: "text/plain;charset=utf-8" }); saveAs(fileBlob, name + ".html"); } function startFile(chat) { return "<table style='background-color: black;'><thead>" + chat + "</thead>"; } function endFile() { return "</table>"; } function formatMessage(curMsg) { var output = "<tr><td style='background-color: white; color: black; padding: 10px; text-align: center;'>"; var playerCol = curMsg.querySelectorAll("div[id^='ujs_LeftCol']")[0].innerText; var messageCol = curMsg.querySelectorAll("div[id^='ujs_Message']")[0].innerText; if (playerCol == "Player Name") { playerCol = ""; } output += playerCol + "</td><td style='background-color: white; color: black; padding: 10px'>" output += messageCol + "</td></tr>" return output; } function doSave() { var chatFinal = prompt("Enter a file name: ", "chat"); if (chatFinal == null) { return; } var date = new Date(); chatFinal = date.getFullYear() + ("0" + date.getMonth().toString()).slice(-2) + ("0" + date.getDay().toString()).slice(-2) + "-" + chatFinal; var output = startFile(chatFinal); var chat = document.getElementById("ujs_ChatContainer_2"); var childNodes = chat.childNodes; for (var i = 0; i < chat.childNodes.length; i++) { var curMsg = childNodes[i]; output += formatMessage(curMsg); } output += endFile(); saveFile(output, chatFinal); } function getModalButton() { return '<button type="button" class="btn btn-primary" id="saveChatButton">Save Clan Chat</button>'; } function initiateSave() { var modalButton = document.createElement("div"); modalButton.innerHTML = getModalButton(); var navBox = document.getElementsByClassName("navbar-nav")[0]; navBox.appendChild(modalButton); var el = document.getElementById("saveChatButton"); if (el.addEventListener) { el.addEventListener("click", doSave, false); } else if (el.attachEvent) { el.attachEvent('onclick', doSave); } } (function() { 'use strict'; initiateSave(); })();