Greasy Fork 还支持 简体中文。

ClanChatSaver

Script created for saving the clan chat into an HTML file. ***Make sure to load chat before using button. Once chat is loaded, click "save clan chat" and select which chat and a name

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         ClanChatSaver
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Script created for saving the clan chat into an HTML file. ***Make sure to load chat before using button. Once chat is loaded, click "save clan chat" and select which chat and a name
// @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 playerCol = curMsg.querySelectorAll("div[id^='ujs_LeftCol']")[0].innerText;
    var messageCol = curMsg.querySelectorAll("div[id^='ujs_Message']")[1];
    var fgColour = messageCol.style.color;
    var bgColour = curMsg.querySelectorAll("div[id^='ujs_BubbleImage']")[1].style.borderImageSource.slice(-16).substring(0, 6);
    if (bgColour == "Bubble") {
        bgColour = "white";
    }
    if (playerCol == "Player Name") {
        playerCol = "";
    }
    var output = "<tr><td style='background-color: " + bgColour + "; color: " + fgColour + "; padding: 10px; text-align: center;'>";
    output += playerCol + "</td><td style='background-color: " + bgColour + "; color: " + fgColour + "; padding: 10px'>"
    output += messageCol.innerText + "</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();
})();