<commit_before>//wow such code
//Ported to Chrome by <NAME> - DOGE donations: D9xQ9V3BqzVcJtUj92immJJYcFsMLmVghq
//Original code by FoxxMD

//create a var to hold DOM element for indicator
var dogeIndicator;
var version = "1.1";

//Check version because of backwards compability issues.
if (typeof(localStorage["version"]) == "undefined") {
    deleteCookie("refresh");
    localStorage["version"] = version;
}


if (!document.getElementById('dogetip_check')) {
    dogeIndicator = document.createElement('div');
    dogeIndicator.setAttribute('id', 'dogetip_check');
} else {
    dogeIndicator = document.getElementById('dogetip_check');
}


//parse current URL and pull subreddit name
function getCurrentSubreddit() {
    var bIndex,
    eIndex,
    url = window.location.href,
        subName;
    bIndex = url.indexOf('/r/') + 3;
    eIndex = url.indexOf('/', bIndex);

    subName = (eIndex === -1 ? url.slice(bIndex) : url.slice(bIndex, eIndex));

    return subName.toLowerCase();
}

//logic to populate indicator
function canTip(subreddit) {
    //such JSON
    var subredditList = JSON.parse(dogetipList),
        tippingStatus = 'Tipping on this subreddit is <b>';

    if (subredditList[subreddit]) {
        tippingStatus = tippingStatus + 'ALLOWED.</b>';
        dogeIndicator.className += ' soAllowed';
    } else if (subredditList[subreddit] === false) {
        tippingStatus = tippingStatus + 'BANNED.</b>';
        dogeIndicator.className += ' soBanned';
    } else if (subredditList[subreddit] == undefined || subredditList[subreddit] == null) {
        tippingStatus = tippingStatus + 'THE WILD WEST.</b></br></br> This subreddit has not explicitly stated whether' + ' tipping is okay so please be a respectable shibe and use good judgment!';
        dogeIndicator.className += ' soWild';
    }

    dogeIndicator.innerHTML = tippingStatus;
    //check if indicator doesn't exist(probably doesn't ever, but better safe than sorry)
    if (!document.getElementById('dogetip_check')) {
        document.body.appendChild(dogeIndicator);
    }
}

//such utility
function removeClass(theObject, theClass) {
    theObject.className = theObject.className.replace(theClass, "");
}

function addClass(theObject, theClass) {
    theObject.className += (' ' + theClass);
}

function persistList(listData) {
    //So JSON! Save the list to a cookie for 5 days
    dogetipList = JSON.stringify(listData);
    localStorage["dogetipList"] = dogetipList;
    setCookie("refresh", false, 1);
    canTip(getCurrentSubreddit());
}

//style indicator to make it less obtrusive once scrolling begins
function makeUnobtrusive() {
    //wow such arbitrary
    if (window.pageYOffset > 100) {
        if (dogeIndicator.className.indexOf('muchSmall') < 0) {
            addClass(dogeIndicator, 'muchSmall');
        }
    } else if (dogeIndicator.className.indexOf('muchSmall') > 0) {
        removeClass(dogeIndicator, 'muchSmall');
    }
}


//a function to set the cookie
function setCookie(name, value, daysToExpiration) {
    var expirationDate = new Date();
    expirationDate.setTime(expirationDate.getTime() + (1000 * 60 * 60 * 24 * daysToExpiration));
    document.cookie = name + "=" + value + "; expires=" + expirationDate.toGMTString();
}

//another function to read cookies easily
function readCookie(name) {
    name += "=";
    cookies = document.cookie.split(";");
    for (i = 0; i < cookies.length; i++) {
        if (cookies[i].trim().indexOf(name) == 0) {
            thisCookie = cookies[i].trim();
            return thisCookie.substring(name.length, thisCookie.length);
        }
    }
}

function deleteCookie(name) {
    document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
}


//so execute
//If the subreddit list isn't already in storage make a request to get it
if (typeof(readCookie("refresh")) === "undefined") {

    var tempSubList = {},
    firstDone = false;

    //get list of allowed/banned top 200 subreddits from wiki<commit_msg>Version 1.1 backwards compability<commit_after>//wow such code
//Ported to Chrome by <NAME> - DOGE donations: D9xQ9V3BqzVcJtUj92immJJYcFsMLmVghq
//Original code by FoxxMD

//create a var to hold DOM element for indicator
var dogeIndicator;
var version = "1.1";

if (!document.getElementById('dogetip_check')) {
    dogeIndicator = document.createElement('div');
    dogeIndicator.setAttribute('id', 'dogetip_check');
} else {
    dogeIndicator = document.getElementById('dogetip_check');
}


//parse current URL and pull subreddit name
function getCurrentSubreddit() {
    var bIndex,
    eIndex,
    url = window.location.href,
        subName;
    bIndex = url.indexOf('/r/') + 3;
    eIndex = url.indexOf('/', bIndex);

    subName = (eIndex === -1 ? url.slice(bIndex) : url.slice(bIndex, eIndex));

    return subName.toLowerCase();
}

//logic to populate indicator
function canTip(subreddit) {
    //such JSON
    var subredditList = JSON.parse(dogetipList),
        tippingStatus = 'Tipping on this subreddit is <b>';

    if (subredditList[subreddit]) {
        tippingStatus = tippingStatus + 'ALLOWED.</b>';
        dogeIndicator.className += ' soAllowed';
    } else if (subredditList[subreddit] === false) {
        tippingStatus = tippingStatus + 'BANNED.</b>';
        dogeIndicator.className += ' soBanned';
    } else if (subredditList[subreddit] == undefined || subredditList[subreddit] == null) {
        tippingStatus = tippingStatus + 'THE WILD WEST.</b></br></br> This subreddit has not explicitly stated whether' + ' tipping is okay so please be a respectable shibe and use good judgment!';
        dogeIndicator.className += ' soWild';
    }

    dogeIndicator.innerHTML = tippingStatus;
    //check if indicator doesn't exist(probably doesn't ever, but better safe than sorry)
    if (!document.getElementById('dogetip_check')) {
        document.body.appendChild(dogeIndicator);
    }
}

//such utility
function removeClass(theObject, theClass) {
    theObject.className = theObject.className.replace(theClass, "");
}

function addClass(theObject, theClass) {
    theObject.className += (' ' + theClass);
}

function persistList(listData) {
    //So JSON! Save the list to a cookie for 5 days
    dogetipList = JSON.stringify(listData);
    localStorage["dogetipList"] = dogetipList;
    setCookie("refresh", false, 1);
    canTip(getCurrentSubreddit());
}

//style indicator to make it less obtrusive once scrolling begins
function makeUnobtrusive() {
    //wow such arbitrary
    if (window.pageYOffset > 100) {
        if (dogeIndicator.className.indexOf('muchSmall') < 0) {
            addClass(dogeIndicator, 'muchSmall');
        }
    } else if (dogeIndicator.className.indexOf('muchSmall') > 0) {
        removeClass(dogeIndicator, 'muchSmall');
    }
}


//a function to set the cookie
function setCookie(name, value, daysToExpiration) {
    var expirationDate = new Date();
    expirationDate.setTime(expirationDate.getTime() + (1000 * 60 * 60 * 24 * daysToExpiration));
    document.cookie = name + "=" + value + "; expires=" + expirationDate.toGMTString();
}

//another function to read cookies easily
function readCookie(name) {
    name += "=";
    cookies = document.cookie.split(";");
    for (i = 0; i < cookies.length; i++) {
        if (cookies[i].trim().indexOf(name) == 0) {
            thisCookie = cookies[i].trim();
            return thisCookie.substring(name.length, thisCookie.length);
        }
    }
}

function deleteCookie(name) {
    document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
}





//Before we execute the XHR:
//Check version because of backwards compability issues.
if (typeof(localStorage["version"]) == "undefined") {
    deleteCookie("refresh");
    localStorage["version"] = version;
}



//so execute
//If the subreddit list isn't already in storage make a request to get it
if (typeof(readCookie("refresh")) === "undefined") {

    var tempSubList = {},
    firstDone = false;

    //get list of allowed/banned top 200 subreddits from wiki
{'fraction_non_alphanumeric': 0.13060307154451242, 'fraction_numerical': 0.010987638906230491, 'mean_word_length': 3.535673839184598, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4391961', 'n_tokens_mistral': 2521, 'n_tokens_neox': 2445, 'n_words': 643}