Show entire conversation for PnW

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

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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 "";
    }
})();