Raw Source
Joeviocoe / Autoblog Comments 2

// ==UserScript==
// @name       Autoblog Comments 2
// @namespace  
// @version    2.0.0
// @description  Autoblog Comments Enhancer 2 (ACE2)     https://openuserjs.org/scripts/joeviocoe/Autoblog_Comments2
// @include      http://*.autoblog.com/*
// @exclude		 *_uac*
// @copyright  2014+, Joeviocoe
// @require    http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js
// @updateURL  https://openuserjs.org/install/Joeviocoe/Autoblog_Comments2.user.js
// @downloadURL  https://openuserjs.org/install/Joeviocoe/Autoblog_Comments2.user.js
// ==/UserScript==

// Copyright (c) 2014, Joeviocoe
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, 
//   this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, 
//   this list of conditions and the following disclaimer in the documentation 
//   and/or other materials provided with the distribution.
// * Neither the name of Joeviocoe nor the names of its contributors 
//   may be used to endorse or promote products derived from this software 
//   without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
// POSSIBILITY OF SUCH DAMAGE.
//
/*jslint browser: true*/
/*global $, jQuery, alert*/

///// Declare Global Variables /////
var Initialize, test, version = '1.0.0', updateURL = 'https://openuserjs.org/scripts/joeviocoe/Autoblog_Comments', reLog, tester;
var input1, input2, input3, input4, input5, input6, input7, input8, input9, input10, input11, input12, toolbar;
var newComments = 0, currentAge = 0, currentEdit = "", unEditFlag = 0;
var editBtn, ignoreBtn, ignoreViewToggleBtn, quoteBtn, sigBtn;
var togglePersist, checkPersist, clearPersist, toolTipHelp;
var status_myComments, status_HighlightAge, status_Linkify, status_expand, status_timer, status_myComments_A, status_HighlightAge_A, status_Linkify_A, status_expand_A, status_gotoLast_A;
var toggleNewComment, expandAll, collapseAll, hasCollapsed, expandComments, setAgeArray, unHighlightAge, Linkify, UnLinkify;
var ageHrs, ageMin, scrollUp, scrollDown, myCommentsOn, myCommentsOff, timerOn, timerOff, home, end, ageCancel;
var scrollUpAge, scrollDownAge, pullUpdate, updateScript,  EditOrQuote, makeEditAll, hideThis, makeEditThis, editPeek;
var tagAge, placeLinks, linkifyContainer, linkifyTextNode, makeEditAll, makeSigBtn, detectChanges, pullUpdate, user, placeSig, getUserSig, resetUserSig;
var arrayAges = [], firstNav = 1, timeSet, restoreWatch, updatePage, reFresh, reflectValue;
var IgnoreList = [], IgnoreAddRemove, ignoreViewToggle, currentIgnore, numIgnored = 0, numIgnored_i = 0, numIgnored_x = 0;

pollingTime = 10;

function Initialize(){
    toggleNewComment();
    expandComments();
    setInterval (function() {
        if ( $('.load-more').length > 0 ) { expandComments(); }
        pullUpdate(newComments);
    }, pollingTime * 1000);
}

function pullUpdate (newComments) {
    var live, loaded, brandNewComments;
    $.ajax({ url: document.URL, success: function(data) { 
        live = data.split('comment-count')[1].split('Comments')[0].match(/\d+/g);
        loaded = $(".comment-count").text().split('Comments')[0].match(/\d+/g);
        brandNewComments = live - loaded; 
        if ( brandNewComments > 0 ) {
            newComments = (+newComments) + (+brandNewComments);
            document.title = "<" + newComments + "> " + document.title.replace(/<[\d+]*\>/g, '');
        }
        document.title = "\u200c" + loaded + " ~ \u200c" + document.title.replace(/\u200c[\w\W]*?\u200c/g, '');
    } 
           });
}

////////////////////////////////////////////////////////////////////////////////////////////////////////
function toggleNewComment() {
    $('.item--new').each(function() { $(this).get(0).click(); });
}
function expandComments() {
    var expand_timer = setInterval (function() { 
        console.log("ACE: running expandComments");
        $('.comment-viewall').not('.open').each(function() { $(this).get(0).click(); });
        if ( $('.load-more').length === 0 ) { clearInterval(expand_timer); }
        $('.load-more').each(function() { $(this).get(0).click(); });
    }, 3000);
}


///////////////////////////////////////////////////////////////////////////////////////////

setTimeout (Initialize, 5000);