Show entire conversation for PnW

Adds an option to enable/disable scrolling through messages. Makes it very easy to send screenshots of conversations.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Show entire conversation for PnW
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds an option to enable/disable scrolling through messages. Makes it very easy to send screenshots of conversations.
// @author       RandomNoobster
// @match        https://politicsandwar.com/inbox/message/id=*
// @icon         https://politicsandwar.com/favicon.ico
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let div = document.querySelectorAll('#rightcolumn div')[2];
    div.style.height = "100%";

    let p = document.querySelectorAll('#rightcolumn > p .btn-default')[0].parentNode;
    let newButton = document.createElement('label');
    newButton.innerHTML = "Enable scrolling:";
    newButton.style.paddingLeft = "10px";

    let checkbox = document.createElement('input');
    checkbox.type = "checkbox";
    checkbox.style.marginLeft = "4px";
    checkbox.onchange = function checkScrolling () {
        if (checkbox.checked){
            div.style.height = "350px";
            setCookie("enableScrolling", true);
        }
        else {
            div.style.height = "100%";
            setCookie("enableScrolling", false);
        }
    };

    let enableScrolling = getCookie("enableScrolling");
    if (enableScrolling == "true") {
        checkbox.checked = true;
        div.style.height = "350px";
    }
    else if (enableScrolling == "false"){
        checkbox.checked = false;
        div.style.height = "100%";
    }
    else {
        setCookie("enableScrolling", true);
    }

    newButton.appendChild(checkbox);
    p.appendChild(newButton);

    function setCookie(cname, cvalue) {
        const d = new Date();
        d.setTime(d.getTime() + (365 * 24 * 60 * 60 * 1000));
        let expires = "expires=" + d.toUTCString();
        document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
    }

    function getCookie(cname) {
        let name = cname + "=";
        let ca = document.cookie.split(';');
        for(let i = 0; i < ca.length; i++) {
            let c = ca[i];
            while (c.charAt(0) == ' ') {
                c = c.substring(1);
            }
            if (c.indexOf(name) == 0) {
                return c.substring(name.length, c.length);
            }
        }
        return "";
    }
})();