<commit_before>// Time-stamp: "2015-05-21 12:47:56 phil"
// Section 7x is for Conkeror internal tweaks (?)
dumpln("72theme");

// Example: darken Astronomy Picture of the Day (APOD)
// register_user_stylesheet(
//     make_css_data_uri(["body{background: black !important; color: grey !important;}",
//                        ":link, :link * {color: #4986dd !important;}",
//                        ":visited, :visited * {color: #d75047 !important;}"],
//                       $url_prefixes = "http://apod.nasa.gov/apod/"));


// Based on http://www.featureblend.com/css-json.html

// With inheritance:
// var cssjson = {
//     ".copy-1":{
//         "font-family":"Verdana, Geneva, Arial, Helvetica, sans-serif",
//         "font-size":"11px",
//         "color":"#CCC"
//     },
//     "div#container div#header":{
//         "CSSJSON-INHERIT-SELECTOR":".copy-1",
//         "position":"absolute",
//         "top":"12px",
//         "left":"4px"
//     }
// }

// TODO write tests
function ph_generate_css (json) {
    var styleStr = "";
    for (var i in json) {
        styleStr += i + " {";
        for (var j in json[i]) {
            if (j == "CSSJSON-INHERIT-SELECTOR") {
                for (var k in json[json[i][j]]) {
                    styleStr += k + ": \"" + json[json[i][j]][k] + " !important\"; ";
                }
            } else {
                styleStr += j + ": \"" + json[i][j] + " !important\"; ";
            }
        }
        styleStr += "} ";
    }
    return styleStr;
}

var ph_dark_css = {
    "*" : {
        "font-style"                : "normal"            ,
        "background"                : "#404040"           ,
        "color"                     : "#cccccc"           ,
        "text-shadow"               : "0px 0px 0px black" ,
        "-moz-border-bottom-colors" : "#505050 #505050"   ,
        "-moz-border-top-colors"    : "#505050 #505050"   ,
        "-moz-border-right-colors"  : "#505050 #505050"   ,
        "-moz-border-left-colors"   : "#505050 #505050"   ,
        "box-shadow"                : "0 0 0 black"       ,
        "-moz-box-shadow"           : "0 0 0 black"       ,
        "border-color"              : "#505050"           ,
        "text-decoration"           : "none"
    },
    "code, pre, code *, pre *" : {
        "color"                     : "#f6f3e8"           ,
        "background-color"          : "#353535"
    },
    ":link, :link *" : {
        "color"                     : "#8ac6f2"
    },
    ":visited, :visited *" : {
        "color"                     : "#95e454"
    },
    "h1, h2, h3, h4, h5, h6" : {
        "color"                     : "white"
    },
    "em" : {
        "background-color"          : "#505050"
    }
};

function darken_page (I) {
    const styles = ph_generate_css(ph_dark_css);
    const document = I.window.buffers.current.document;
    if (document.createStyleSheet) {
        document.createStyleSheet("javascript:'" + styles + "'");
    } else {
        const newSS = document.createElement('link');
        newSS.rel = 'stylesheet';
        newSS.href = 'data:text/css,' + escape(styles);
        document.getElementsByTagName("head")[0].appendChild(newSS);
    }
}

// function darken_page (I) {
//     var newSS, styles='* { background: #404040 ! important; color: #cccccc !important }'
//         + ':link, :link * { color: #8ac6f2 !important }'
//         + ':visited, :visited * { color: #95e454 !important }';

//     var document = I.window.buffers.current.document;

//     if (document.createStyleSheet) {
//         document.createStyleSheet("javascript:'" + styles + "'");
//     } else {
//         newSS=document.createElement('link');
//         newSS.rel='stylesheet';
//         newSS.href='data:text/css,'+escape(styles);
//         document.getElementsByTagName("head")[0].appendChild(newSS);
//     }
// }

interactive("darken-page", "Darken the page in an attempt to save your eyes.",
            darken_page);

define_key(content_buffer_normal_keymap, "C-M-d", "darken-page");



<commit_msg>Use template strings.<commit_after>// Time-stamp: "2018-12-27 20:06:48 phil"
// Section 7x is for Conkeror internal tweaks (?)
dumpln("72theme");

// Example: darken Astronomy Picture of the Day (APOD)
// register_user_stylesheet(
//     make_css_data_uri(["body{background: black !important; color: grey !important;}",
//                        ":link, :link * {color: #4986dd !important;}",
//                        ":visited, :visited * {color: #d75047 !important;}"],
//                       $url_prefixes = "http://apod.nasa.gov/apod/"));


// Based on http://www.featureblend.com/css-json.html

// With inheritance:
// var cssjson = {
//     ".copy-1":{
//         "font-family":"Verdana, Geneva, Arial, Helvetica, sans-serif",
//         "font-size":"11px",
//         "color":"#CCC"
//     },
//     "div#container div#header":{
//         "CSSJSON-INHERIT-SELECTOR":".copy-1",
//         "position":"absolute",
//         "top":"12px",
//         "left":"4px"
//     }
// }

// TODO write tests
function ph_generate_css (json) {
    var styleStr = "";
    for (var i in json) {
        styleStr += i + " {";
        for (var j in json[i]) {
            if (j == "CSSJSON-INHERIT-SELECTOR") {
                for (var k in json[json[i][j]]) {
                    styleStr += `${k}: "${json[json[i][j]][k]} !important"; `;
                }
            } else {
                styleStr += `${j}: "${json[i][j]} !important"; `;
            }
        }
        styleStr += "} ";
    }
    return styleStr;
}

var ph_dark_css = {
    "*" : {
        "font-style"                : "normal"            ,
        "background"                : "#404040"           ,
        "color"                     : "#cccccc"           ,
        "text-shadow"               : "0px 0px 0px black" ,
        "-moz-border-bottom-colors" : "#505050 #505050"   ,
        "-moz-border-top-colors"    : "#505050 #505050"   ,
        "-moz-border-right-colors"  : "#505050 #505050"   ,
        "-moz-border-left-colors"   : "#505050 #505050"   ,
        "box-shadow"                : "0 0 0 black"       ,
        "-moz-box-shadow"           : "0 0 0 black"       ,
        "border-color"              : "#505050"           ,
        "text-decoration"           : "none"
    },
    "code, pre, code *, pre *" : {
        "color"                     : "#f6f3e8"           ,
        "background-color"          : "#353535"
    },
    ":link, :link *" : {
        "color"                     : "#8ac6f2"
    },
    ":visited, :visited *" : {
        "color"                     : "#95e454"
    },
    "h1, h2, h3, h4, h5, h6" : {
        "color"                     : "white"
    },
    "em" : {
        "background-color"          : "#505050"
    }
};

function darken_page (I) {
    const styles = ph_generate_css(ph_dark_css);
    const document = I.window.buffers.current.document;
    if (document.createStyleSheet) {
        document.createStyleSheet(`javascript:'${styles}'`);
    } else {
        const newSS = document.createElement('link');
        newSS.rel = 'stylesheet';
        newSS.href = `data:text/css,${escape(styles)}`;
        document.getElementsByTagName("head")[0].appendChild(newSS);
    }
}

// function darken_page (I) {
//     var newSS, styles='* { background: #404040 ! important; color: #cccccc !important }'
//         + ':link, :link * { color: #8ac6f2 !important }'
//         + ':visited, :visited * { color: #95e454 !important }';

//     var document = I.window.buffers.current.document;

//     if (document.createStyleSheet) {
//         document.createStyleSheet("javascript:'" + styles + "'");
//     } else {
//         newSS=document.createElement('link');
//         newSS.rel='stylesheet';
//         newSS.href='data:text/css,'+escape(styles);
//         document.getElementsByTagName("head")[0].appendChild(newSS);
//     }
// }

interactive("darken-page", "Darken the page in an attempt to save your eyes.",
            darken_page);

define_key(content_buffer_normal_keymap, "C-M-d", "darken-page");




{'fraction_non_alphanumeric': 0.1802649498576204, 'fraction_numerical': 0.03639965333663489, 'mean_word_length': 1.6819389110225764, 'pattern_counts': {'":': 28, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5639893', 'n_tokens_mistral': 2813, 'n_tokens_neox': 2622, 'n_words': 478}